Skip to content
Browse files

wpf toolkit assembly added and method hotspots know their class and n…

…amespace for better grouping
  • Loading branch information...
1 parent 5684c4b commit 0c7127a7e38f63c81cc35c67a5354cf2f6e2ca2b @halllo halllo committed Oct 23, 2012
View
BIN Sources/Libs/WPFToolkit.dll
Binary file not shown.
View
18 Sources/Usus.net.Core/Reports/MetricsReport.cs
@@ -23,6 +23,7 @@ private static void AddTypesOf(MetricsReport[] reports, MetricsReport combinedRe
Dictionary<string, TypeMetricsWithMethodMetrics> typeReports;
Dictionary<string, NamespaceMetricsWithTypeMetrics> namespaceReports;
+ Dictionary<MethodMetricsReport, TypeMetricsReport> methodToType;
internal MutableGraph<TypeMetricsReport> GraphOfTypes { get; set; }
internal MutableGraph<NamespaceMetricsWithTypeMetrics> GraphOfNamespaces { get; set; }
@@ -61,6 +62,7 @@ internal MetricsReport()
CommonKnowledge = new CommonReportKnowledge();
typeReports = new Dictionary<string, TypeMetricsWithMethodMetrics>();
namespaceReports = new Dictionary<string, NamespaceMetricsWithTypeMetrics>();
+ methodToType = new Dictionary<MethodMetricsReport, TypeMetricsReport>();
}
internal void AddNamespaceReport(NamespaceMetricsWithTypeMetrics namespaceMertics)
@@ -95,10 +97,15 @@ internal IEnumerable<MethodMetricsReport> MethodsOf(TypeMetricsReport type)
return typeReports[type.FullName].Methods;
}
- internal IEnumerable<TypeMetricsReport> TypesOf(NamespaceMetricsReport namespaceMetrics)
- {
- return namespaceReports[namespaceMetrics.Name].Types;
- }
+ internal TypeMetricsReport TypeOf(MethodMetricsReport methodMetrics)
+ {
+ return methodToType[methodMetrics];
+ }
+
+ internal IEnumerable<TypeMetricsReport> TypesOf(NamespaceMetricsReport namespaceMetrics)
+ {
+ return namespaceReports[namespaceMetrics.Name].Types;
+ }
private void ShareTheKnowledgeWithMethodsOf(TypeMetricsWithMethodMetrics typeMertics)
{
@@ -107,6 +114,9 @@ private void ShareTheKnowledgeWithMethodsOf(TypeMetricsWithMethodMetrics typeMer
{
CommonKnowledge.UpdateFor(method);
method.CommonKnowledge = CommonKnowledge;
+
+ if (!methodToType.ContainsKey(method))
+ methodToType.Add(method, typeMertics.Itself);
}
}
}
View
8 Sources/Usus.net.Core/Reports/MetricsReportSearch.cs
@@ -9,9 +9,9 @@ public static IEnumerable<MethodMetricsReport> MethodsOfType(this MetricsReport
return metrics.MethodsOf(typeMetrics);
}
- public static IEnumerable<TypeMetricsReport> TypesOfNamespace(this MetricsReport metrics, NamespaceMetricsReport namespaceMetrics)
- {
- return metrics.TypesOf(namespaceMetrics);
- }
+ public static IEnumerable<TypeMetricsReport> TypesOfNamespace(this MetricsReport metrics, NamespaceMetricsReport namespaceMetrics)
+ {
+ return metrics.TypesOf(namespaceMetrics);
+ }
}
}
View
5 Sources/Usus.net.Core/Reports/TypeMetricsReportSearch.cs
@@ -20,5 +20,10 @@ public static TypeMetricsReport ForType(this MetricsReport metrics, string typeN
{
return metrics.TypeForName(typeName);
}
+
+ public static TypeMetricsReport ForTypeOf(this MetricsReport metrics, MethodMetricsReport methodMetrics)
+ {
+ return metrics.TypeOf(methodMetrics);
+ }
}
}
View
3 Sources/Usus.net.View/Usus.net.View.csproj
@@ -57,6 +57,9 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<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>
<Compile Include="CleanCode.xaml.cs">
View
2 Sources/Usus.net.View/ViewModels/Hotspots/HotspotClassSize.cs
@@ -1,3 +1,4 @@
+using System.Linq;
using andrena.Usus.net.Core.Reports;
namespace andrena.Usus.net.View.ViewModels.Hotspots
@@ -7,6 +8,7 @@ public class HotspotClassSize : TypeHotspot
public int Size { get { return Report.ClassSize; } }
public string Class { get { return Report.Name; } }
public string Fullname { get { return Report.FullName; } }
+ public string Namespace { get { return Report.Namespaces.First(); } }
public HotspotClassSize(TypeMetricsReport type, MetricsReport metrics)
: base(type, metrics)
View
2 Sources/Usus.net.View/ViewModels/Hotspots/HotspotCumulativeComponentDependency.cs
@@ -1,3 +1,4 @@
+using System.Linq;
using andrena.Usus.net.Core.Reports;
namespace andrena.Usus.net.View.ViewModels.Hotspots
@@ -7,6 +8,7 @@ public class HotspotCumulativeComponentDependency : TypeHotspot
public int Dependencies { get { return Report.CumulativeComponentDependency; } }
public string Class { get { return Report.Name; } }
public string Fullname { get { return Report.FullName; } }
+ public string Namespace { get { return Report.Namespaces.First(); } }
public HotspotCumulativeComponentDependency(TypeMetricsReport type, MetricsReport metrics)
: base(type, metrics)
View
10 Sources/Usus.net.View/ViewModels/Hotspots/HotspotCyclomaticComplexity.cs
@@ -1,16 +1,22 @@
+using System.Linq;
using andrena.Usus.net.Core.Reports;
namespace andrena.Usus.net.View.ViewModels.Hotspots
{
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 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)
{
+ mMetrics = metrics;
}
}
}
View
12 Sources/Usus.net.View/ViewModels/Hotspots/HotspotMethodLength.cs
@@ -1,16 +1,22 @@
+using System.Linq;
using andrena.Usus.net.Core.Reports;
namespace andrena.Usus.net.View.ViewModels.Hotspots
{
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 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)
{
+ mMetrics = metrics;
}
- }
+ }
}
View
2 Sources/Usus.net.View/ViewModels/Hotspots/HotspotNonStaticPublicFields.cs
@@ -1,3 +1,4 @@
+using System.Linq;
using andrena.Usus.net.Core.Reports;
namespace andrena.Usus.net.View.ViewModels.Hotspots
@@ -7,6 +8,7 @@ public class HotspotNonStaticPublicFields : TypeHotspot
public int Count { get { return Report.NumberOfNonStaticPublicFields; } }
public string Class { get { return Report.Name; } }
public string Fullname { get { return Report.FullName; } }
+ public string Namespace { get { return Report.Namespaces.First(); } }
public HotspotNonStaticPublicFields(TypeMetricsReport type, MetricsReport metrics)
: base(type, metrics)
View
12 Sources/Usus.net.View/ViewModels/Hotspots/HotspotsCollection.cs
@@ -46,8 +46,8 @@ protected override void AnalysisFinished(PreparedMetricsReport metrics)
Dispatch(ClearLists);
Dispatch(() => SetClassSizes(metrics.ClassSizeHotspots, metrics.Report));
Dispatch(() => SetCumulativeComponentDependencies(metrics.CumulativeComponentDependencyHotspots, metrics.Report));
- Dispatch(() => SetCyclomaticComplexities(metrics.CyclomaticComplexityHotspots));
- Dispatch(() => SetMethodLengths(metrics.MethodLengthHotspots));
+ Dispatch(() => SetCyclomaticComplexities(metrics.CyclomaticComplexityHotspots, metrics.Report));
+ Dispatch(() => SetMethodLengths(metrics.MethodLengthHotspots, metrics.Report));
Dispatch(() => SetNamespacesInCycle(metrics.NumberOfNamespacesInCycleHotspots, metrics.Report));
Dispatch(() => SetNonStaticPublicFields(metrics.NumberOfNonStaticPublicFieldsHotspots, metrics.Report));
}
@@ -64,16 +64,16 @@ private void SetCumulativeComponentDependencies(IEnumerable<TypeMetricsReport> c
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),
- 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),
- m => new HotspotMethodLength(m));
+ m => new HotspotMethodLength(m, metrics));
}
private void SetNamespacesInCycle(IEnumerable<NamespaceMetricsReport> namespacesInCycle, MetricsReport metrics)

0 comments on commit 0c7127a

Please sign in to comment.
Something went wrong with that request. Please try again.