Browse Source

- Cleaned AssemblyInfo.cs

- Small tweaks to Dependency Matrix
- Implementation of Relationships. For now only for Namespace.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6218 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Tomáš Linhart 16 years ago
parent
commit
bb695bfd0c
  1. 44
      src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
  2. 11
      src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.sln
  3. 26
      src/AddIns/Analysis/CodeQuality/Properties/AssemblyInfo.cs
  4. 3
      src/AddIns/Analysis/CodeQuality/Src/App.xaml
  5. 2
      src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrix.cs
  6. 9
      src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrixControl.cs
  7. 7
      src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs
  8. 6
      src/AddIns/Analysis/CodeQuality/Src/Event.cs
  9. 6
      src/AddIns/Analysis/CodeQuality/Src/Field.cs
  10. 1
      src/AddIns/Analysis/CodeQuality/Src/INode.cs
  11. 6
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml
  12. 10
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs
  13. 6
      src/AddIns/Analysis/CodeQuality/Src/Method.cs
  14. 6
      src/AddIns/Analysis/CodeQuality/Src/Module.cs
  15. 144
      src/AddIns/Analysis/CodeQuality/Src/Namespace.cs
  16. 32
      src/AddIns/Analysis/CodeQuality/Src/Relationship.cs
  17. 16
      src/AddIns/Analysis/CodeQuality/Src/RelationshipType.cs
  18. 11
      src/AddIns/Analysis/CodeQuality/Src/Type.cs
  19. 8
      src/AddIns/Analysis/CodeQuality/Themes/Generic.xaml

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

@ -32,26 +32,45 @@
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<OutputPath>..\..\..\..\AddIns\AddIns\Misc\CodeQualityAnalysis\</OutputPath> <OutputPath>..\..\..\..\AddIns\AddIns\Misc\CodeQualityAnalysis\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<DebugType>None</DebugType>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'Debug' ">
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'Release' ">
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="GraphSharp"> <Reference Include="GraphSharp">
<HintPath>..\..\..\Libraries\GraphSharp\GraphSharp.dll</HintPath> <HintPath>..\..\..\Libraries\GraphSharp\GraphSharp.dll</HintPath>
@ -73,6 +92,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -84,6 +104,9 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="WindowsFormsIntegration">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WPFExtensions"> <Reference Include="WPFExtensions">
<HintPath>..\..\..\Libraries\GraphSharp\WPFExtensions.dll</HintPath> <HintPath>..\..\..\Libraries\GraphSharp\WPFExtensions.dll</HintPath>
</Reference> </Reference>
@ -93,6 +116,9 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Properties\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Src\Controls\DependencyEdge.cs" /> <Compile Include="Src\Controls\DependencyEdge.cs" />
<Compile Include="Src\Controls\DependencyGraph.cs" /> <Compile Include="Src\Controls\DependencyGraph.cs" />
<Compile Include="Src\Controls\DependencyGraphLayout.cs" /> <Compile Include="Src\Controls\DependencyGraphLayout.cs" />
@ -110,6 +136,8 @@
<Compile Include="Src\MetricsReader.cs" /> <Compile Include="Src\MetricsReader.cs" />
<Compile Include="Src\Method.cs" /> <Compile Include="Src\Method.cs" />
<Compile Include="Src\Namespace.cs" /> <Compile Include="Src\Namespace.cs" />
<Compile Include="Src\Relationship.cs" />
<Compile Include="Src\RelationshipType.cs" />
<Compile Include="Src\Type.cs" /> <Compile Include="Src\Type.cs" />
<Page Include="Resources\GraphTemplate.xaml"> <Page Include="Resources\GraphTemplate.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
@ -127,6 +155,7 @@
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Page Include="Themes\Generic.xaml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Src\Module.cs" /> <Compile Include="Src\Module.cs" />
@ -209,6 +238,9 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Themes" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.

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

@ -1,6 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 11.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010 # Visual Studio 2010
# SharpDevelop 4.0.0.6197
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQualityAnalysis", "CodeQualityAnalysis.csproj", "{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQualityAnalysis", "CodeQualityAnalysis.csproj", "{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}"
@ -13,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "..\..
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -59,6 +62,14 @@ Global
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU
{8035765F-D51F-4A0C-A746-2FD100E19419}.Release|x86.ActiveCfg = Release|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|x86.ActiveCfg = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|x86.Build.0 = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|x86.ActiveCfg = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.Build.0 = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|x86.Build.0 = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

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

@ -7,20 +7,12 @@ using System.Windows;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Code-Quality-Analysis")] [assembly: AssemblyTitle("CodeQualityAnalysis")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("The CodeQualityAnalysis provides useful tools for analyzing assemblies and show dependencies between them.")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Code-Quality-Analysis")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [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 //In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file //<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english //inside a <PropertyGroup>. For example, if you are using US english
@ -39,17 +31,3 @@ using System.Windows;
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries) // 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")]

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

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

2
src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrix.cs

@ -9,7 +9,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
{ {
public override object EvaluateCell(MatrixCell<INode> rowHeader, MatrixCell<INode> columnHeader) public override object EvaluateCell(MatrixCell<INode> rowHeader, MatrixCell<INode> columnHeader)
{ {
return rowHeader.Value == columnHeader.Value; // TODO: Add a new method to INode Uses(INode -> Boolean) or maybe Relatioship(INode -> Relatioship) return rowHeader.Value.GetRelationship(columnHeader.Value);
} }
} }
} }

9
src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyMatrixControl.cs

@ -1,11 +1,20 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions;
using System.Text; using System.Text;
using System.Windows;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.CodeQualityAnalysis.Controls namespace ICSharpCode.CodeQualityAnalysis.Controls
{ {
public class DependencyMatrixControl : MatrixControl<INode> public class DependencyMatrixControl : MatrixControl<INode>
{ {
static DependencyMatrixControl()
{
DefaultStyleKeyProperty.OverrideMetadata(
typeof(DependencyMatrixControl),
new FrameworkPropertyMetadata(typeof(DependencyMatrixControl)));
}
} }
} }

7
src/AddIns/Analysis/CodeQuality/Src/Controls/MatrixControl.cs

@ -95,12 +95,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
}); });
label.Style = style; label.Style = style;
/*label.RenderTransform = new RotateTransform() // need some tweaking label.LayoutTransform = new RotateTransform { Angle = -90 };
{
Angle = -90,
CenterX = -10,
CenterY = 40
};*/
Children.Add(label); Children.Add(label);
} }

6
src/AddIns/Analysis/CodeQuality/Src/Event.cs

@ -33,6 +33,12 @@ namespace ICSharpCode.CodeQualityAnalysis
return Name; return Name;
} }
public Relationship GetRelationship(INode node)
{
Relationship relationship = new Relationship();
return relationship;
}
public IDependency Dependency { get; set; } public IDependency Dependency { get; set; }
public string GetInfo() public string GetInfo()

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

@ -77,6 +77,12 @@ namespace ICSharpCode.CodeQualityAnalysis
Dependency = null; Dependency = null;
} }
public Relationship GetRelationship(INode node)
{
Relationship relationship = new Relationship();
return relationship;
}
public override string ToString() public override string ToString()
{ {
return Name; return Name;

1
src/AddIns/Analysis/CodeQuality/Src/INode.cs

@ -10,5 +10,6 @@ namespace ICSharpCode.CodeQualityAnalysis
string Name { set; get; } string Name { set; get; }
IDependency Dependency { set; get; } IDependency Dependency { set; get; }
string GetInfo(); string GetInfo();
Relationship GetRelationship(INode node);
} }
} }

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

@ -46,13 +46,15 @@
HighlightAlgorithmType="Simple" HighlightAlgorithmType="Simple"
VertexClick="graphLayout_VertexClick" VertexClick="graphLayout_VertexClick"
/> />
</Controls:ZoomControl> </Controls:ZoomControl>
<TextBlock Name="txbTypeInfo" Grid.Column="3" Grid.Row="1"/> <TextBlock Name="txbTypeInfo" Grid.Column="3" Grid.Row="1"/>
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="Dependency Matrix"> <TabItem Header="Dependency Matrix">
<Graph:DependencyMatrixControl x:Name="matrixControl"></Graph:DependencyMatrixControl> <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
<Graph:DependencyMatrixControl x:Name="matrixControl"></Graph:DependencyMatrixControl>
</ScrollViewer>
</TabItem> </TabItem>
</TabControl> </TabControl>
</Window> </Window>

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

@ -30,7 +30,6 @@ namespace ICSharpCode.CodeQualityAnalysis
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
private MetricsReader _metricsReader; private MetricsReader _metricsReader;
private VertexControl _selectedVertexControl;
public MainWindow() public MainWindow()
{ {
@ -135,10 +134,15 @@ namespace ICSharpCode.CodeQualityAnalysis
{ {
var matrix = new DependencyMatrix(); var matrix = new DependencyMatrix();
foreach (var ns in _metricsReader.MainModule.Namespaces) foreach (var ns in _metricsReader.MainModule.Namespaces) {
{
matrix.HeaderRows.Add(new MatrixCell<INode>(ns)); matrix.HeaderRows.Add(new MatrixCell<INode>(ns));
foreach (var type in ns.Types) {
matrix.HeaderRows.Add(new MatrixCell<INode>(type));
}
matrix.HeaderColumns.Add(new MatrixCell<INode>(ns)); matrix.HeaderColumns.Add(new MatrixCell<INode>(ns));
foreach (var type in ns.Types) {
matrix.HeaderColumns.Add(new MatrixCell<INode>(type));
}
} }
matrixControl.Matrix = matrix; matrixControl.Matrix = matrix;

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

@ -120,6 +120,12 @@ namespace ICSharpCode.CodeQualityAnalysis
Dependency = null; Dependency = null;
} }
public Relationship GetRelationship(INode node)
{
Relationship relationship = new Relationship();
return relationship;
}
public override string ToString() public override string ToString()
{ {
return Name; return Name;

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

@ -59,6 +59,12 @@ namespace ICSharpCode.CodeQualityAnalysis
return g; return g;
} }
public Relationship GetRelationship(INode node)
{
Relationship relationship = new Relationship();
return relationship;
}
public override string ToString() public override string ToString()
{ {
return Name; return Name;

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

@ -60,6 +60,150 @@ namespace ICSharpCode.CodeQualityAnalysis
return g; return g;
} }
public Relationship GetRelationship(INode node)
{
Relationship relationship = new Relationship();
if (node == this) {
relationship.Relationships.Add(RelationshipType.Same);
return relationship;
}
if (node is Namespace) {
Namespace ns = (Namespace)node;
foreach (var type in ns.Types)
{
if (Types.Contains(type)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
}
if (node is Type) {
Type type = (Type)node;
if (this.Types.Contains(type.BaseType)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
foreach (var thisType in type.GenericImplementedInterfacesTypes) {
if (this.Types.Contains(thisType)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
foreach (var thisType in type.ImplementedInterfaces) {
if (this.Types.Contains(thisType)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
if (this.Types.Contains(type)) {
relationship.Relationships.Add(RelationshipType.Contains);
}
}
if (node is Method) {
Method method = (Method)node;
if (this.Types.Contains(method.ReturnType)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
foreach (var type in method.GenericReturnTypes) {
if (this.Types.Contains(type)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
foreach (var parameter in method.Parameters) {
if (this.Types.Contains(parameter.ParameterType)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
foreach (var type in parameter.GenericTypes) {
if (this.Types.Contains(type)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
}
foreach (var type in method.TypeUses) {
if (this.Types.Contains(type)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
foreach (var type in method.TypeUses) {
if (this.Types.Contains(type)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
foreach (var field in method.FieldUses) {
foreach (var type in this.Types) {
if (type.Fields.Contains(field)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
}
foreach (var meth in method.MethodUses) {
foreach (var type in this.Types) {
if (type.Methods.Contains(meth)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
}
foreach (var type in method.TypeUses) {
if (this.Types.Contains(type)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
if (this.Types.Contains(method.Owner))
relationship.Relationships.Add(RelationshipType.Contains);
}
if (node is Field) {
Field field = (Field)node;
if (this.Types.Contains(field.FieldType)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
foreach (var type in field.GenericTypes) {
if (this.Types.Contains(type)) {
relationship.NumberOfOccurrences++;
relationship.Relationships.Add(RelationshipType.UseThis);
}
}
if (this.Types.Contains(field.Owner))
relationship.Relationships.Add(RelationshipType.Contains);
}
return relationship;
}
public override string ToString() public override string ToString()
{ {
return Name; return Name;

32
src/AddIns/Analysis/CodeQuality/Src/Relationship.cs

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ICSharpCode.CodeQualityAnalysis
{
/// <summary>
/// Description of Relationship.
/// </summary>
public class Relationship
{
public ISet<RelationshipType> Relationships { get; private set; }
public int NumberOfOccurrences { get; set; }
public Relationship()
{
Relationships = new HashSet<RelationshipType>();
NumberOfOccurrences = 0;
}
public override string ToString()
{
var builder = new StringBuilder();
foreach (var relationship in Relationships)
builder.Append(relationship + " ");
builder.Append(NumberOfOccurrences);
return builder.ToString();
}
}
}

16
src/AddIns/Analysis/CodeQuality/Src/RelationshipType.cs

@ -0,0 +1,16 @@

namespace ICSharpCode.CodeQualityAnalysis
{
/// <summary>
/// Description of RelationshipType.
/// </summary>
public enum RelationshipType
{
OneWayTo,
UseThis,
UsedBy,
Same,
Contains,
None
}
}

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

@ -243,6 +243,17 @@ namespace ICSharpCode.CodeQualityAnalysis
return g; return g;
} }
public Relationship GetRelationship(INode node)
{
// if (node is Namespace) {
// Namespace ns = (Namespace)node;
// if (ns.Types.Contains(this)
// return RelationshipType.Contains;
// }
return new Relationship();
}
public override string ToString() public override string ToString()
{ {
return Name; return Name;

8
src/AddIns/Analysis/CodeQuality/Themes/Generic.xaml

@ -0,0 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls"
>
<Style TargetType="{x:Type Controls:DependencyMatrixControl}">
<Setter Property="ShowGridLines" Value="True" />
</Style>
</ResourceDictionary>
Loading…
Cancel
Save