Skip to content

Commit

Permalink
wpf toolkit assembly added and method hotspots know their class and n…
Browse files Browse the repository at this point in the history
…amespace for better grouping
  • Loading branch information
halllo committed Oct 23, 2012
1 parent 5684c4b commit 0c7127a
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 19 deletions.
Binary file added Sources/Libs/WPFToolkit.dll
Binary file not shown.
18 changes: 14 additions & 4 deletions Sources/Usus.net.Core/Reports/MetricsReport.cs
Expand Up @@ -23,6 +23,7 @@ private static void AddTypesOf(MetricsReport[] reports, MetricsReport combinedRe


Dictionary<string, TypeMetricsWithMethodMetrics> typeReports; Dictionary<string, TypeMetricsWithMethodMetrics> typeReports;
Dictionary<string, NamespaceMetricsWithTypeMetrics> namespaceReports; Dictionary<string, NamespaceMetricsWithTypeMetrics> namespaceReports;
Dictionary<MethodMetricsReport, TypeMetricsReport> methodToType;


internal MutableGraph<TypeMetricsReport> GraphOfTypes { get; set; } internal MutableGraph<TypeMetricsReport> GraphOfTypes { get; set; }
internal MutableGraph<NamespaceMetricsWithTypeMetrics> GraphOfNamespaces { get; set; } internal MutableGraph<NamespaceMetricsWithTypeMetrics> GraphOfNamespaces { get; set; }
Expand Down Expand Up @@ -61,6 +62,7 @@ internal MetricsReport()
CommonKnowledge = new CommonReportKnowledge(); CommonKnowledge = new CommonReportKnowledge();
typeReports = new Dictionary<string, TypeMetricsWithMethodMetrics>(); typeReports = new Dictionary<string, TypeMetricsWithMethodMetrics>();
namespaceReports = new Dictionary<string, NamespaceMetricsWithTypeMetrics>(); namespaceReports = new Dictionary<string, NamespaceMetricsWithTypeMetrics>();
methodToType = new Dictionary<MethodMetricsReport, TypeMetricsReport>();
} }


internal void AddNamespaceReport(NamespaceMetricsWithTypeMetrics namespaceMertics) internal void AddNamespaceReport(NamespaceMetricsWithTypeMetrics namespaceMertics)
Expand Down Expand Up @@ -95,10 +97,15 @@ internal IEnumerable<MethodMetricsReport> MethodsOf(TypeMetricsReport type)
return typeReports[type.FullName].Methods; return typeReports[type.FullName].Methods;
} }


internal IEnumerable<TypeMetricsReport> TypesOf(NamespaceMetricsReport namespaceMetrics) internal TypeMetricsReport TypeOf(MethodMetricsReport methodMetrics)
{ {
return namespaceReports[namespaceMetrics.Name].Types; return methodToType[methodMetrics];
} }

internal IEnumerable<TypeMetricsReport> TypesOf(NamespaceMetricsReport namespaceMetrics)
{
return namespaceReports[namespaceMetrics.Name].Types;
}


private void ShareTheKnowledgeWithMethodsOf(TypeMetricsWithMethodMetrics typeMertics) private void ShareTheKnowledgeWithMethodsOf(TypeMetricsWithMethodMetrics typeMertics)
{ {
Expand All @@ -107,6 +114,9 @@ private void ShareTheKnowledgeWithMethodsOf(TypeMetricsWithMethodMetrics typeMer
{ {
CommonKnowledge.UpdateFor(method); CommonKnowledge.UpdateFor(method);
method.CommonKnowledge = CommonKnowledge; method.CommonKnowledge = CommonKnowledge;

if (!methodToType.ContainsKey(method))
methodToType.Add(method, typeMertics.Itself);
} }
} }
} }
Expand Down
8 changes: 4 additions & 4 deletions Sources/Usus.net.Core/Reports/MetricsReportSearch.cs
Expand Up @@ -9,9 +9,9 @@ public static IEnumerable<MethodMetricsReport> MethodsOfType(this MetricsReport
return metrics.MethodsOf(typeMetrics); return metrics.MethodsOf(typeMetrics);
} }


public static IEnumerable<TypeMetricsReport> TypesOfNamespace(this MetricsReport metrics, NamespaceMetricsReport namespaceMetrics) public static IEnumerable<TypeMetricsReport> TypesOfNamespace(this MetricsReport metrics, NamespaceMetricsReport namespaceMetrics)
{ {
return metrics.TypesOf(namespaceMetrics); return metrics.TypesOf(namespaceMetrics);
} }
} }
} }
5 changes: 5 additions & 0 deletions Sources/Usus.net.Core/Reports/TypeMetricsReportSearch.cs
Expand Up @@ -20,5 +20,10 @@ public static TypeMetricsReport ForType(this MetricsReport metrics, string typeN
{ {
return metrics.TypeForName(typeName); return metrics.TypeForName(typeName);
} }

public static TypeMetricsReport ForTypeOf(this MetricsReport metrics, MethodMetricsReport methodMetrics)
{
return metrics.TypeOf(methodMetrics);
}
} }
} }
3 changes: 3 additions & 0 deletions Sources/Usus.net.View/Usus.net.View.csproj
Expand Up @@ -57,6 +57,9 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\Libs\WPFToolkit.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CleanCode.xaml.cs"> <Compile Include="CleanCode.xaml.cs">
Expand Down
2 changes: 2 additions & 0 deletions Sources/Usus.net.View/ViewModels/Hotspots/HotspotClassSize.cs
@@ -1,3 +1,4 @@
using System.Linq;
using andrena.Usus.net.Core.Reports; using andrena.Usus.net.Core.Reports;


namespace andrena.Usus.net.View.ViewModels.Hotspots namespace andrena.Usus.net.View.ViewModels.Hotspots
Expand All @@ -7,6 +8,7 @@ public class HotspotClassSize : TypeHotspot
public int Size { get { return Report.ClassSize; } } public int Size { get { return Report.ClassSize; } }
public string Class { get { return Report.Name; } } public string Class { get { return Report.Name; } }
public string Fullname { get { return Report.FullName; } } public string Fullname { get { return Report.FullName; } }
public string Namespace { get { return Report.Namespaces.First(); } }


public HotspotClassSize(TypeMetricsReport type, MetricsReport metrics) public HotspotClassSize(TypeMetricsReport type, MetricsReport metrics)
: base(type, metrics) : base(type, metrics)
Expand Down
@@ -1,3 +1,4 @@
using System.Linq;
using andrena.Usus.net.Core.Reports; using andrena.Usus.net.Core.Reports;


namespace andrena.Usus.net.View.ViewModels.Hotspots namespace andrena.Usus.net.View.ViewModels.Hotspots
Expand All @@ -7,6 +8,7 @@ public class HotspotCumulativeComponentDependency : TypeHotspot
public int Dependencies { get { return Report.CumulativeComponentDependency; } } public int Dependencies { get { return Report.CumulativeComponentDependency; } }
public string Class { get { return Report.Name; } } public string Class { get { return Report.Name; } }
public string Fullname { get { return Report.FullName; } } public string Fullname { get { return Report.FullName; } }
public string Namespace { get { return Report.Namespaces.First(); } }


public HotspotCumulativeComponentDependency(TypeMetricsReport type, MetricsReport metrics) public HotspotCumulativeComponentDependency(TypeMetricsReport type, MetricsReport metrics)
: base(type, metrics) : base(type, metrics)
Expand Down
@@ -1,16 +1,22 @@
using System.Linq;
using andrena.Usus.net.Core.Reports; using andrena.Usus.net.Core.Reports;


namespace andrena.Usus.net.View.ViewModels.Hotspots namespace andrena.Usus.net.View.ViewModels.Hotspots
{ {
public class HotspotCyclomaticComplexity : MethodHotspot public class HotspotCyclomaticComplexity : MethodHotspot
{ {
public int Complexity { get { return Report.CyclomaticComplexity; } } private readonly MetricsReport mMetrics;

public int Complexity { get { return Report.CyclomaticComplexity; } }
public string Method { get { return Report.Name; } } public string Method { get { return Report.Name; } }
public string Signature { get { return Report.Signature; } } public string Signature { get { return Report.Signature; } }
public string Type { get { return mMetrics.ForTypeOf(Report).FullName; } }
public string Namespace { get { return mMetrics.ForTypeOf(Report).Namespaces.First(); } }


public HotspotCyclomaticComplexity(MethodMetricsReport method) public HotspotCyclomaticComplexity(MethodMetricsReport method, MetricsReport metrics)
: base(method) : base(method)
{ {
mMetrics = metrics;
} }
} }
} }
12 changes: 9 additions & 3 deletions Sources/Usus.net.View/ViewModels/Hotspots/HotspotMethodLength.cs
@@ -1,16 +1,22 @@
using System.Linq;
using andrena.Usus.net.Core.Reports; using andrena.Usus.net.Core.Reports;


namespace andrena.Usus.net.View.ViewModels.Hotspots namespace andrena.Usus.net.View.ViewModels.Hotspots
{ {
public class HotspotMethodLength : MethodHotspot public class HotspotMethodLength : MethodHotspot
{ {
public int Length { get { return Report.MethodLength; } } private readonly MetricsReport mMetrics;

public int Length { get { return Report.MethodLength; } }
public string Method { get { return Report.Name; } } public string Method { get { return Report.Name; } }
public string Signature { get { return Report.Signature; } } public string Signature { get { return Report.Signature; } }
public string Type { get { return mMetrics.ForTypeOf(Report).FullName; } }
public string Namespace { get { return mMetrics.ForTypeOf(Report).Namespaces.First(); } }


public HotspotMethodLength(MethodMetricsReport method) public HotspotMethodLength(MethodMetricsReport method, MetricsReport metrics)
: base(method) : base(method)
{ {
mMetrics = metrics;
} }
} }
} }
@@ -1,3 +1,4 @@
using System.Linq;
using andrena.Usus.net.Core.Reports; using andrena.Usus.net.Core.Reports;


namespace andrena.Usus.net.View.ViewModels.Hotspots namespace andrena.Usus.net.View.ViewModels.Hotspots
Expand All @@ -7,6 +8,7 @@ public class HotspotNonStaticPublicFields : TypeHotspot
public int Count { get { return Report.NumberOfNonStaticPublicFields; } } public int Count { get { return Report.NumberOfNonStaticPublicFields; } }
public string Class { get { return Report.Name; } } public string Class { get { return Report.Name; } }
public string Fullname { get { return Report.FullName; } } public string Fullname { get { return Report.FullName; } }
public string Namespace { get { return Report.Namespaces.First(); } }


public HotspotNonStaticPublicFields(TypeMetricsReport type, MetricsReport metrics) public HotspotNonStaticPublicFields(TypeMetricsReport type, MetricsReport metrics)
: base(type, metrics) : base(type, metrics)
Expand Down
12 changes: 6 additions & 6 deletions Sources/Usus.net.View/ViewModels/Hotspots/HotspotsCollection.cs
Expand Up @@ -46,8 +46,8 @@ protected override void AnalysisFinished(PreparedMetricsReport metrics)
Dispatch(ClearLists); Dispatch(ClearLists);
Dispatch(() => SetClassSizes(metrics.ClassSizeHotspots, metrics.Report)); Dispatch(() => SetClassSizes(metrics.ClassSizeHotspots, metrics.Report));
Dispatch(() => SetCumulativeComponentDependencies(metrics.CumulativeComponentDependencyHotspots, metrics.Report)); Dispatch(() => SetCumulativeComponentDependencies(metrics.CumulativeComponentDependencyHotspots, metrics.Report));
Dispatch(() => SetCyclomaticComplexities(metrics.CyclomaticComplexityHotspots)); Dispatch(() => SetCyclomaticComplexities(metrics.CyclomaticComplexityHotspots, metrics.Report));
Dispatch(() => SetMethodLengths(metrics.MethodLengthHotspots)); Dispatch(() => SetMethodLengths(metrics.MethodLengthHotspots, metrics.Report));
Dispatch(() => SetNamespacesInCycle(metrics.NumberOfNamespacesInCycleHotspots, metrics.Report)); Dispatch(() => SetNamespacesInCycle(metrics.NumberOfNamespacesInCycleHotspots, metrics.Report));
Dispatch(() => SetNonStaticPublicFields(metrics.NumberOfNonStaticPublicFieldsHotspots, metrics.Report)); Dispatch(() => SetNonStaticPublicFields(metrics.NumberOfNonStaticPublicFieldsHotspots, metrics.Report));
} }
Expand All @@ -64,16 +64,16 @@ private void SetCumulativeComponentDependencies(IEnumerable<TypeMetricsReport> c
m => new HotspotCumulativeComponentDependency(m, metrics)); m => new HotspotCumulativeComponentDependency(m, metrics));
} }


private void SetCyclomaticComplexities(IEnumerable<MethodMetricsReport> cyclomaticComplexities) private void SetCyclomaticComplexities(IEnumerable<MethodMetricsReport> cyclomaticComplexities, MetricsReport metrics)
{ {
SetHotspots(CyclomaticComplexities, cyclomaticComplexities.OrderByDescending(m => m.CyclomaticComplexity), SetHotspots(CyclomaticComplexities, cyclomaticComplexities.OrderByDescending(m => m.CyclomaticComplexity),
m => new HotspotCyclomaticComplexity(m)); m => new HotspotCyclomaticComplexity(m, metrics));
} }


private void SetMethodLengths(IEnumerable<MethodMetricsReport> methodLengths) private void SetMethodLengths(IEnumerable<MethodMetricsReport> methodLengths, MetricsReport metrics)
{ {
SetHotspots(MethodLengths, methodLengths.OrderByDescending(m => m.MethodLength), SetHotspots(MethodLengths, methodLengths.OrderByDescending(m => m.MethodLength),
m => new HotspotMethodLength(m)); m => new HotspotMethodLength(m, metrics));
} }


private void SetNamespacesInCycle(IEnumerable<NamespaceMetricsReport> namespacesInCycle, MetricsReport metrics) private void SetNamespacesInCycle(IEnumerable<NamespaceMetricsReport> namespacesInCycle, MetricsReport metrics)
Expand Down

0 comments on commit 0c7127a

Please sign in to comment.