Browse Source

Initial commit of Code Quality Analysis AddIn.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5893 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Tomáš Linhart 16 years ago
parent
commit
19b4d75de9
  1. 9
      SharpDevelop.sln
  2. 173
      src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
  3. 20
      src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.sln
  4. 55
      src/AddIns/Analysis/CodeQuality/Properties/AssemblyInfo.cs
  5. 63
      src/AddIns/Analysis/CodeQuality/Properties/Resources.Designer.cs
  6. 117
      src/AddIns/Analysis/CodeQuality/Properties/Resources.resx
  7. 26
      src/AddIns/Analysis/CodeQuality/Properties/Settings.Designer.cs
  8. 7
      src/AddIns/Analysis/CodeQuality/Properties/Settings.settings
  9. 8
      src/AddIns/Analysis/CodeQuality/Src/App.xaml
  10. 16
      src/AddIns/Analysis/CodeQuality/Src/App.xaml.cs
  11. 26
      src/AddIns/Analysis/CodeQuality/Src/Field.cs
  12. 14
      src/AddIns/Analysis/CodeQuality/Src/IDependency.cs
  13. 39
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml
  14. 115
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs
  15. 48
      src/AddIns/Analysis/CodeQuality/Src/Method.cs
  16. 361
      src/AddIns/Analysis/CodeQuality/Src/MetricsReader.cs
  17. 31
      src/AddIns/Analysis/CodeQuality/Src/Module.cs
  18. 54
      src/AddIns/Analysis/CodeQuality/Src/Namespace.cs
  19. 99
      src/AddIns/Analysis/CodeQuality/Src/Type.cs
  20. BIN
      src/Libraries/GraphSharp/GraphSharp.Contracts.dll
  21. BIN
      src/Libraries/GraphSharp/GraphSharp.Controls.dll
  22. BIN
      src/Libraries/GraphSharp/GraphSharp.dll
  23. BIN
      src/Libraries/GraphSharp/Microsoft.Contracts.dll
  24. BIN
      src/Libraries/GraphSharp/QuickGraph.dll
  25. BIN
      src/Libraries/GraphSharp/WPFExtensions.dll

9
SharpDevelop.sln

@ -123,6 +123,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\ @@ -123,6 +123,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQualityAnalysis", "src\AddIns\Analysis\CodeQuality\CodeQualityAnalysis.csproj", "{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}"
ProjectSection(ProjectDependencies) = postProject
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "src\AddIns\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}"
ProjectSection(ProjectDependencies) = postProject
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}
@ -679,6 +684,10 @@ Global @@ -679,6 +684,10 @@ Global
{3EAA45A9-735C-4AC7-A799-947B93EA449D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3EAA45A9-735C-4AC7-A799-947B93EA449D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3EAA45A9-735C-4AC7-A799-947B93EA449D}.Release|Any CPU.Build.0 = Release|Any CPU
{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Any CPU.Build.0 = Release|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU

173
src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj

@ -0,0 +1,173 @@ @@ -0,0 +1,173 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ICSharpCode.CodeQualityAnalysis</RootNamespace>
<AssemblyName>CodeQualityAnalysis</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<OutputPath>..\..\..\..\AddIns\AddIns\Misc\CodeQualityAnalysis\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="GraphSharp">
<HintPath>..\..\..\Libraries\GraphSharp\GraphSharp.dll</HintPath>
</Reference>
<Reference Include="GraphSharp.Contracts">
<HintPath>..\..\..\Libraries\GraphSharp\GraphSharp.Contracts.dll</HintPath>
</Reference>
<Reference Include="GraphSharp.Controls">
<HintPath>..\..\..\Libraries\GraphSharp\GraphSharp.Controls.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Contracts">
<HintPath>..\..\..\Libraries\GraphSharp\Microsoft.Contracts.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil">
<HintPath>..\..\..\Libraries\Mono.Cecil\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="QuickGraph">
<HintPath>..\..\..\Libraries\GraphSharp\QuickGraph.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WPFExtensions">
<HintPath>..\..\..\Libraries\GraphSharp\WPFExtensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="Src\App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Src\Field.cs" />
<Compile Include="Src\IDependency.cs" />
<Compile Include="Src\MetricsReader.cs" />
<Compile Include="Src\Method.cs" />
<Compile Include="Src\Namespace.cs" />
<Compile Include="Src\Type.cs" />
<Page Include="Src\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="Src\App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Src\Module.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="CodeQualityAnalysis.addin" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

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

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQualityAnalysis", "CodeQualityAnalysis.csproj", "{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|x86.ActiveCfg = Debug|x86
{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|x86.Build.0 = Debug|x86
{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|x86.ActiveCfg = Release|x86
{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

55
src/AddIns/Analysis/CodeQuality/Properties/AssemblyInfo.cs

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Code-Quality-Analysis")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Code-Quality-Analysis")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

63
src/AddIns/Analysis/CodeQuality/Properties/Resources.Designer.cs generated

@ -0,0 +1,63 @@ @@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ICSharpCode.CodeQualityAnalysis.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ICSharpCode.CodeQualityAnalysis.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

117
src/AddIns/Analysis/CodeQuality/Properties/Resources.resx

@ -0,0 +1,117 @@ @@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

26
src/AddIns/Analysis/CodeQuality/Properties/Settings.Designer.cs generated

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ICSharpCode.CodeQualityAnalysis.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

7
src/AddIns/Analysis/CodeQuality/Properties/Settings.settings

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

8
src/AddIns/Analysis/CodeQuality/Src/App.xaml

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
<Application x:Class="ICSharpCode.CodeQualityAnalysis.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Src\MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

16
src/AddIns/Analysis/CodeQuality/Src/App.xaml.cs

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
namespace ICSharpCode.CodeQualityAnalysis
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

26
src/AddIns/Analysis/CodeQuality/Src/Field.cs

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuickGraph;
namespace ICSharpCode.CodeQualityAnalysis
{
public class Field : IDependency
{
/// <summary>
/// Name of field
/// </summary>
public string Name { get; set; }
/// <summary>
/// Type of field
/// </summary>
public Type Type { get; set; }
public BidirectionalGraph<object, IEdge<object>> BuildDependencyGraph()
{
return null;
}
}
}

14
src/AddIns/Analysis/CodeQuality/Src/IDependency.cs

@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuickGraph;
namespace ICSharpCode.CodeQualityAnalysis
{
public interface IDependency
{
string Name { set; get; }
BidirectionalGraph<object, IEdge<object>> BuildDependencyGraph();
}
}

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

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
<Window x:Class="ICSharpCode.CodeQualityAnalysis.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:graphsharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
xmlns:zoom="clr-namespace:WPFExtensions.Controls;assembly=WPFExtensions"
Title="Code Quality Analysis"
x:Name="root">
<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">
<ToolBar>
<Button Name="btnOpenAssembly" Click="btnOpenAssembly_Click">Open Assembly</Button>
</ToolBar>
</ToolBarTray>
<TreeView Name="definitionTree" Grid.Row="1" Grid.Column="0" SelectedItemChanged="definitionTree_SelectedItemChanged" />
<!-- gonna replace with ISharpDevelop ZoomControl -->
<zoom:ZoomControl ForceCursor="True" Grid.Row="1" Grid.Column="1" Name="zoom">
<graphsharp:GraphLayout x:Name="graphLayout"
LayoutAlgorithmType="LinLog"
OverlapRemovalAlgorithmType="FSA"
HighlightAlgorithmType="Simple"
/>
</zoom:ZoomControl>
<TextBlock Name="txbTypeInfo" Grid.Column="3" Grid.Row="1"/>
</Grid>
</Window>

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

@ -0,0 +1,115 @@ @@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Win32;
using Mono.Cecil;
using Mono.Cecil.Cil;
using QuickGraph;
using QuickGraph.Collections;
namespace ICSharpCode.CodeQualityAnalysis
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private MetricsReader _metricsReader;
public MainWindow()
{
InitializeComponent();
}
private void btnOpenAssembly_Click(object sender, RoutedEventArgs e)
{
var fileDialog = new OpenFileDialog
{
Filter = "Component Files (*.dll, *.exe)|*.dll;*.exe"
};
fileDialog.ShowDialog();
if (String.IsNullOrEmpty(fileDialog.FileName))
return;
definitionTree.Items.Clear();
_metricsReader = new MetricsReader(fileDialog.FileName);
FillTree();
}
/// <summary>
/// Fill tree with module, types and methods and TODO: fields
/// </summary>
private void FillTree()
{
var itemModule = new MetricTreeViewItem() { Header = _metricsReader.MainModule.Name, Dependency = _metricsReader.MainModule };
definitionTree.Items.Add(itemModule);
foreach (var ns in _metricsReader.MainModule.Namespaces)
{
var nsType = new MetricTreeViewItem() { Header = ns.Name, Dependency = ns };
itemModule.Items.Add(nsType);
foreach (var type in ns.Types)
{
var itemType = new MetricTreeViewItem() { Header = type.Name, Dependency = type };
nsType.Items.Add(itemType);
foreach (var method in type.Methods)
{
var itemMethod = new MetricTreeViewItem() { Header = method.Name, Dependency = method };
itemType.Items.Add(itemMethod);
}
foreach (var field in type.Fields)
{
var itemField = new MetricTreeViewItem() { Header = field.Name, Dependency = field };
itemType.Items.Add(itemField);
}
}
}
}
private void definitionTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
var item = definitionTree.SelectedItem as MetricTreeViewItem;
if (item != null)
{
// would be better inherit from TreeViewItem and add reference into it
// will do it later or will use another tree maybe tree from SharpDevelop
string name = item.Header.ToString();
txbTypeInfo.Text = "Infobox: \n" + name;
/*var type = (from n in this._metricsReader.MainModule.Namespaces
from t in n.Types
where t.Name == name
select t).SingleOrDefault();*/
var graph = item.Dependency.BuildDependencyGraph();
if (graph != null && graph.VertexCount > 0)
{
graphLayout.Graph = graph;
}
}
}
private class MetricTreeViewItem : TreeViewItem
{
public IDependency Dependency { get; set; }
}
}
}

48
src/AddIns/Analysis/CodeQuality/Src/Method.cs

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuickGraph;
namespace ICSharpCode.CodeQualityAnalysis
{
public class Method : IDependency
{
/// <summary>
/// Types which are used in body of method
/// </summary>
public ISet<Type> TypeUses { get; set; }
/// <summary>
/// Methods which are called in body of method
/// </summary>
public ISet<Method> MethodUses { get; set; }
/// <summary>
/// Fields which are accesed in body of method
/// </summary>
public ISet<Field> FieldUses { get; set; }
/// <summary>
/// A name of method
/// </summary>
public string Name { get; set; }
/// <summary>
/// A return type of method
/// </summary>
public Type Type { get; set; }
public Method()
{
TypeUses = new HashSet<Type>();
MethodUses = new HashSet<Method>();
FieldUses = new HashSet<Field>();
}
public BidirectionalGraph<object, IEdge<object>> BuildDependencyGraph()
{
return null;
}
}
}

361
src/AddIns/Analysis/CodeQuality/Src/MetricsReader.cs

@ -0,0 +1,361 @@ @@ -0,0 +1,361 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
namespace ICSharpCode.CodeQualityAnalysis
{
/// <summary>
/// Reads neccesery information with Mono.Cecil to calculate code metrics
/// </summary>
public class MetricsReader
{
public Module MainModule { get; private set; }
public MetricsReader(string file)
{
this.ReadAssembly(file);
}
/// <summary>
/// Opens file as assembly and starts reading MainModule
/// </summary>
/// <param name="file"></param>
private void ReadAssembly(string file)
{
var assembly = AssemblyDefinition.ReadAssembly(file);
ReadModule(assembly.MainModule);
}
/// <summary>
/// Reads main module from assembly
/// </summary>
/// <param name="moduleDefinition"></param>
private void ReadModule(ModuleDefinition moduleDefinition)
{
this.MainModule = new Module()
{
Name = moduleDefinition.Name
};
ReadTypes(MainModule, moduleDefinition.Types);
}
/// <summary>
/// Reads types from module
/// </summary>
/// <param name="module"></param>
/// <param name="types"></param>
private void ReadTypes(Module module, Collection<TypeDefinition> types)
{
// first add all types, because i will need find depend types
foreach (TypeDefinition typeDefinition in types)
{
if (typeDefinition.Name != "<Module>")
{
var type = new Type()
{
FullName = FormatTypeName(typeDefinition),
Name = FormatTypeName(typeDefinition)
};
// try find namespace
var nsName = GetNamespaceName(typeDefinition);
var ns = (from n in module.Namespaces
where n.Name == nsName
select n).SingleOrDefault();
if (ns == null)
{
ns = new Namespace()
{
Name = nsName,
Module = module
};
module.Namespaces.Add(ns);
}
type.Namespace = ns;
ns.Types.Add(type);
}
}
foreach (TypeDefinition typeDefinition in types)
{
if (typeDefinition.Name != "<Module>")
{
var type =
(from n in module.Namespaces
from t in n.Types
where (t.Name == FormatTypeName(typeDefinition))
select t).SingleOrDefault();
if (typeDefinition.HasFields)
ReadFields(type, typeDefinition.Fields);
/*if (typeDefinition.HasEvents)
ReadEvents(type, typeDefinition.Events);*/
if (typeDefinition.HasMethods)
ReadMethods(type, typeDefinition.Methods);
/*if (typeDefinition.HasConstructors)
ReadConstructors(type, typeDefinition.Constructors);*/
}
}
}
private void ReadEvents(Type type, Collection<EventDefinition> events)
{
throw new NotImplementedException();
}
/// <summary>
/// Reads fields and add them to field list for type
/// </summary>
/// <param name="type"></param>
/// <param name="fields"></param>
private void ReadFields(Type type, Collection<FieldDefinition> fields)
{
foreach (FieldDefinition fieldDefinition in fields)
{
var field = new Field()
{
Name = fieldDefinition.Name
};
type.Fields.Add(field);
var declaringType =
(from n in type.Namespace.Module.Namespaces
from t in n.Types
where t.Name == field.Name
select t).SingleOrDefault();
field.Type = declaringType;
}
}
/// <summary>
/// Extracts methods and add them to method list for type
/// </summary>
/// <param name="type"></param>
/// <param name="methods"></param>
private void ReadMethods(Type type, Collection<MethodDefinition> methods)
{
foreach (MethodDefinition methodDefinition in methods)
{
var method = new Method
{
Name = FormatMethodName(methodDefinition),
Type = type
};
type.Methods.Add(method);
}
foreach (MethodDefinition methodDefinition in methods)
{
var method = (from m in type.Methods
where m.Name == FormatMethodName(methodDefinition)
select m).SingleOrDefault();
if (methodDefinition.Body != null)
{
ReadInstructions(method, methodDefinition, methodDefinition.Body.Instructions);
}
}
}
/// <summary>
/// Reads constructors and add them to method list for type
/// </summary>
/// <param name="type"></param>
/// <param name="constructors"></param>
private void ReadConstructors(Type type, Collection<MethodDefinition> constructors)
{
foreach (MethodDefinition constructor in constructors)
{
var method = new Method
{
Name = FormatMethodName(constructor),
Type = type
};
type.Methods.Add(method);
}
foreach (MethodDefinition constructor in constructors)
{
var method = (from m in type.Methods
where m.Name == FormatMethodName(constructor)
select m).SingleOrDefault();
if (constructor.Body != null)
{
ReadInstructions(method, constructor, constructor.Body.Instructions);
}
}
}
/// <summary>
/// Reads method calls by extracting instrunctions
/// </summary>
/// <param name="method"></param>
/// <param name="methodDefinition"></param>
/// <param name="instructions"></param>
public void ReadInstructions(Method method, MethodDefinition methodDefinition,
Collection<Instruction> instructions)
{
foreach (Instruction instruction in instructions)
{
var instr = ReadInstruction(instruction);
if (instr is MethodDefinition)
{
var md = instr as MethodDefinition;
var type = (from n in method.Type.Namespace.Module.Namespaces
from t in n.Types
where t.Name == FormatTypeName(md.DeclaringType) &&
n.Name == t.Namespace.Name
select t).SingleOrDefault();
method.TypeUses.Add(type);
var findTargetMethod = (from m in type.Methods
where m.Name == FormatMethodName(md)
select m).SingleOrDefault();
if (findTargetMethod != null && type == method.Type)
method.MethodUses.Add(findTargetMethod);
}
if (instr is FieldDefinition)
{
var fd = instr as FieldDefinition;
var field = (from f in method.Type.Fields
where f.Name == fd.Name
select f).SingleOrDefault();
if (field != null)
method.FieldUses.Add(field);
}
}
}
/// <summary>
/// Reads instruction operand by recursive calling until non-instruction
/// operand is found
/// </summary>
/// <param name="instruction"></param>
/// <returns></returns>
public object ReadInstruction(Instruction instruction)
{
if (instruction.Operand == null)
return null;
var nextInstruction = instruction.Operand as Instruction;
if (nextInstruction != null)
return ReadInstruction(nextInstruction);
else
return instruction.Operand;
}
/// <summary>
/// Formats method name by adding parameters to it. If there are not any parameters
/// only empty brackers will be added.
/// </summary>
/// <param name="methodDefinition"></param>
/// <returns></returns>
public string FormatMethodName(MethodDefinition methodDefinition)
{
if (methodDefinition.HasParameters)
{
var builder = new StringBuilder();
var enumerator = methodDefinition.Parameters.GetEnumerator();
bool hasNext = enumerator.MoveNext();
while (hasNext)
{
builder.Append(((ParameterDefinition) enumerator.Current).ParameterType.FullName);
hasNext = enumerator.MoveNext();
if (hasNext)
builder.Append(", ");
}
return methodDefinition.Name + "(" + builder.ToString() + ")";
}
else
{
return methodDefinition.Name + "()";
}
}
/// <summary>
/// Formats a specific type name. If type is generic. Brackets <> will be added with proper names of parameters.
/// </summary>
/// <param name="typeDefinition"></param>
/// <returns></returns>
public string FormatTypeName(TypeDefinition typeDefinition)
{
if (typeDefinition.IsNested && typeDefinition.DeclaringType != null)
{
return FormatTypeName(typeDefinition.DeclaringType) + "+" + typeDefinition.Name;
}
if (typeDefinition.HasGenericParameters)
{
var builder = new StringBuilder();
var enumerator = typeDefinition.GenericParameters.GetEnumerator();
bool hasNext = enumerator.MoveNext();
while (hasNext)
{
builder.Append(((GenericParameter)enumerator.Current).Name);
hasNext = enumerator.MoveNext();
if (hasNext)
builder.Append(",");
}
return StripGenericName(typeDefinition.Name) + "<" + builder.ToString() + ">";
}
return typeDefinition.Name;
}
/// <summary>
/// Removes a number of generics parameters. Eg. `3 will be removed from end of name.
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
private string StripGenericName(string name)
{
return name.IndexOf('`') != -1 ? name.Remove(name.IndexOf('`')) : name;
}
/// <summary>
/// Gets namespace name. If type is nested it looks recursively to parent type until finds his namespace.
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
private string GetNamespaceName(TypeDefinition type)
{
if (type.IsNested && type.DeclaringType != null)
return GetNamespaceName(type.DeclaringType);
else
{
if (!String.IsNullOrEmpty(type.Namespace))
return type.Namespace;
else
return "-";
}
}
}
}

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

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuickGraph;
namespace ICSharpCode.CodeQualityAnalysis
{
public class Module : IDependency
{
/// <summary>
/// Namespaces within module
/// </summary>
public ISet<Namespace> Namespaces { get; set; }
/// <summary>
/// Name of module
/// </summary>
public string Name { get; set; }
public Module()
{
Namespaces = new HashSet<Namespace>();
}
public BidirectionalGraph<object, IEdge<object>> BuildDependencyGraph()
{
return null;
}
}
}

54
src/AddIns/Analysis/CodeQuality/Src/Namespace.cs

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuickGraph;
namespace ICSharpCode.CodeQualityAnalysis
{
public class Namespace : IDependency
{
/// <summary>
/// Types within namespace
/// </summary>
public ISet<Type> Types { get; set; }
/// <summary>
/// Name of namespace
/// </summary>
public string Name { get; set; }
/// <summary>
/// Module where is namespace located
/// </summary>
public Module Module { get; set; }
public Namespace()
{
Types = new HashSet<Type>();
}
public BidirectionalGraph<object, IEdge<object>> BuildDependencyGraph()
{
var g = new BidirectionalGraph<object, IEdge<object>>();
foreach (var type in Types)
{
g.AddVertex(type.Name);
}
foreach (var type in Types)
{
var types = type.GetUses();
foreach (var dependType in types)
{
if (dependType != type && dependType.Namespace == type.Namespace)
g.AddEdge(new Edge<object>(type.Name, dependType.Name));
}
}
return g;
}
}
}

99
src/AddIns/Analysis/CodeQuality/Src/Type.cs

@ -0,0 +1,99 @@ @@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuickGraph;
namespace ICSharpCode.CodeQualityAnalysis
{
public class Type : IDependency
{
/// <summary>
/// Nested types like inner classes, interfaces and so on.
/// </summary>
public ISet<Type> InnerTypes { get; set; }
/// <summary>
/// Methods within type
/// </summary>
public ISet<Method> Methods { get; set; }
/// <summary>
/// Fields within type
/// </summary>
public ISet<Field> Fields { get; set; }
/// <summary>
/// Name of type with a name of namespace.
/// </summary>
public string FullName { get; set; }
/// <summary>
/// Name of type
/// </summary>
public string Name { get; set; }
/// <summary>
/// Namespace where type is located
/// </summary>
public Namespace Namespace { get; set; }
public Type()
{
Methods = new HashSet<Method>();
Fields = new HashSet<Field>();
}
/// <summary>
/// Returns all types which are used in this type
/// </summary>
/// <returns>A set of types</returns>
public ISet<Type> GetUses()
{
var set = new HashSet<Type>();
foreach (var method in Methods)
{
set.UnionWith(method.TypeUses);
}
foreach (var field in Fields)
{
if (field.Type != null) // if it is null so it is type from outside of this assembly
set.Add(field.Type); // TODO: find solution to handle them
}
return set;
}
public BidirectionalGraph<object, IEdge<object>> BuildDependencyGraph()
{
var g = new BidirectionalGraph<object, IEdge<object>>();
foreach (var method in Methods)
{
g.AddVertex(method.Name);
}
foreach (var field in Fields)
{
g.AddVertex(field.Name);
}
foreach (var method in Methods)
{
foreach (var methodUse in method.MethodUses)
{
g.AddEdge(new Edge<object>(method.Name, methodUse.Name));
}
foreach (var fieldUse in method.FieldUses)
{
g.AddEdge(new Edge<object>(method.Name, fieldUse.Name));
}
}
return g;
}
}
}

BIN
src/Libraries/GraphSharp/GraphSharp.Contracts.dll

Binary file not shown.

BIN
src/Libraries/GraphSharp/GraphSharp.Controls.dll

Binary file not shown.

BIN
src/Libraries/GraphSharp/GraphSharp.dll

Binary file not shown.

BIN
src/Libraries/GraphSharp/Microsoft.Contracts.dll

Binary file not shown.

BIN
src/Libraries/GraphSharp/QuickGraph.dll

Binary file not shown.

BIN
src/Libraries/GraphSharp/WPFExtensions.dll

Binary file not shown.
Loading…
Cancel
Save