diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 12:47:52 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 12:47:52 +0400 |
commit | ee2d0b4c759506548fe27cbad776c8add326e23c (patch) | |
tree | 1b5045e2543598803e5d466c31c08573a04dcb51 /main/src | |
parent | b4d5199daf6492f88d350e1701c750752120b838 (diff) |
[CodeMetrics] Track API changes.
Diffstat (limited to 'main/src')
5 files changed, 20 insertions, 18 deletions
diff --git a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/ClassProperties.cs b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/ClassProperties.cs index 1f6aa8dd52..417b6e3340 100644 --- a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/ClassProperties.cs +++ b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/ClassProperties.cs @@ -297,8 +297,8 @@ namespace MonoDevelop.CodeMetrics AddField (); this.FieldCount = this.Fields.Count; - this.EventCount = this.Class.Events.Count; - this.MethodCount = this.Methods.Count; + this.EventCount = this.Class.Events.Count (); + this.MethodCount = this.Methods.Count (); this.StartLine = this.Class.BodyRegion.BeginLine; this.EndLine = this.Class.BodyRegion.EndLine; } diff --git a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/CodeMetricsServices.cs b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/CodeMetricsServices.cs index 41da4fe834..8daf65f208 100644 --- a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/CodeMetricsServices.cs +++ b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/CodeMetricsServices.cs @@ -36,6 +36,7 @@ using MonoDevelop.Projects; using Mono.TextEditor; using ICSharpCode.NRefactory.TypeSystem; using MonoDevelop.TypeSystem; +using System.Linq; namespace MonoDevelop.CodeMetrics { @@ -43,8 +44,8 @@ namespace MonoDevelop.CodeMetrics { public static void AddTypes (ProjectProperties projectprop, MetricsContext ctx) { - var dom = TypeSystemService.GetProjectContext (projectprop.Project); - foreach (var ob in dom.GetTypes ()) { + var dom = TypeSystemService.GetCompilation (projectprop.Project); + foreach (var ob in dom.MainAssembly.GetAllTypeDefinitions ()) { projectprop.AddInstance(ob); } } @@ -133,7 +134,7 @@ namespace MonoDevelop.CodeMetrics results.Append(GettextCatalog.GetString("\nInner classes : ") + item.InnerClassCount); results.Append(GettextCatalog.GetString("\nStructs : ") + item.StructCount); results.Append(GettextCatalog.GetString("\nMethods : ") + item.MethodCount); - results.Append(GettextCatalog.GetString("\nProperties : ") + item.Class.Properties.Count); + results.Append(GettextCatalog.GetString("\nProperties : ") + item.Class.Properties.Count ()); results.Append(GettextCatalog.GetString("\nLack of cohesion of methods : ") + item.LCOM); results.Append(GettextCatalog.GetString("\nLack of cohesion of methods (Henderson-Sellers) : ") + item.LCOM_HS); return results; @@ -155,8 +156,8 @@ namespace MonoDevelop.CodeMetrics { StringBuilder results = new StringBuilder(); results.Append(GettextCatalog.GetString("\nName : " + item.FullName)); - results.Append(GettextCatalog.GetString("\nTotal number of fields : " + item.Struct.Fields.Count)); - results.Append(GettextCatalog.GetString("\nTotal number of properties : " + item.Struct.Properties.Count)); + results.Append(GettextCatalog.GetString("\nTotal number of fields : " + item.Struct.Fields.Count ())); + results.Append(GettextCatalog.GetString("\nTotal number of properties : " + item.Struct.Properties.Count ())); return results; } @@ -164,8 +165,8 @@ namespace MonoDevelop.CodeMetrics { StringBuilder results = new StringBuilder(); results.Append(GettextCatalog.GetString("\nName : " + item.FullName)); - results.Append(GettextCatalog.GetString("\nTotal number of properties : " + item.Interface.Properties.Count)); - results.Append(GettextCatalog.GetString("\nTotal number of methods : " + item.Interface.Methods.Count)); + results.Append(GettextCatalog.GetString("\nTotal number of properties : " + item.Interface.Properties.Count ())); + results.Append(GettextCatalog.GetString("\nTotal number of methods : " + item.Interface.Methods.Count ())); return results; } diff --git a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/Cohesion.cs b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/Cohesion.cs index 4ea171e134..1d8c6b1698 100644 --- a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/Cohesion.cs +++ b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/Cohesion.cs @@ -36,6 +36,7 @@ using MonoDevelop.Core; using MonoDevelop.Ide.Gui; using MonoDevelop.Projects; using Mono.TextEditor; +using System.Linq; namespace MonoDevelop.CodeMetrics { @@ -47,8 +48,8 @@ namespace MonoDevelop.CodeMetrics foreach (var field in cls.Fields) totalaccess += field.Value.InternalAccessCount; - cls.LCOM = 1 - (double)(totalaccess/(cls.Class.Methods.Count*cls.Class.Fields.Count)); - cls.LCOM_HS = (cls.Class.Methods.Count - totalaccess/cls.Class.Fields.Count)/(cls.Class.Methods.Count-1); + cls.LCOM = 1 - (double)(totalaccess/(cls.Class.Methods.Count()*cls.Class.Fields.Count())); + cls.LCOM_HS = (cls.Class.Methods.Count() - totalaccess/cls.Class.Fields.Count())/(cls.Class.Methods.Count()-1); } /* diff --git a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/InheritanceTree.cs b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/InheritanceTree.cs index 19ac17b1a4..7e5c1d6331 100644 --- a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/InheritanceTree.cs +++ b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/InheritanceTree.cs @@ -35,7 +35,7 @@ namespace MonoDevelop.CodeMetrics { private static void ClassEvaluateInheritanceTree (MetricsContext ctx, ClassProperties cls) { - foreach (var ob in cls.Class.GetAllBaseTypeDefinitions (cls.Class.ProjectContent)) { + foreach (var ob in cls.Class.GetAllBaseTypeDefinitions ()) { if (ob.Kind == TypeKind.Class && ob != cls.Class && ob.Name!="Object") { cls.DepthOfInheritance++; ClassProperties tmp = ctx.GetInstanceOf (ob); diff --git a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/NamespaceProperties.cs b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/NamespaceProperties.cs index 18f68be147..265b9805ba 100644 --- a/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/NamespaceProperties.cs +++ b/main/src/addins/MonoDevelop.CodeMetrics/MonoDevelop.CodeMetrics/NamespaceProperties.cs @@ -146,7 +146,7 @@ namespace MonoDevelop.CodeMetrics key.Append(type.FullName); foreach(var typeArg in type.TypeParameters) { - foreach(var constraint in typeArg.GetConstraints (type.ProjectContent)) { + foreach(var constraint in typeArg.DirectBaseTypes) { key.Append(" " + constraint); } } @@ -176,7 +176,7 @@ namespace MonoDevelop.CodeMetrics lock(Classes) { foreach(var typeArg in cls.TypeParameters) { - foreach(var constraint in typeArg.GetConstraints (cls.ProjectContent)) { + foreach(var constraint in typeArg.DirectBaseTypes) { key.Append(constraint.ToString ()); } } @@ -191,7 +191,7 @@ namespace MonoDevelop.CodeMetrics lock(Structs) { foreach(var typeArg in strct.TypeParameters) { - foreach(var constraint in typeArg.GetConstraints (strct.ProjectContent)) { + foreach(var constraint in typeArg.DirectBaseTypes) { key.Append(constraint.ToString ()); } } @@ -206,7 +206,7 @@ namespace MonoDevelop.CodeMetrics lock(Interfaces) { foreach(var typeArg in interfce.TypeParameters) { - foreach(var constraint in typeArg.GetConstraints (interfce.ProjectContent)) { + foreach(var constraint in typeArg.DirectBaseTypes) { key.Append(constraint.ToString ()); } } @@ -221,7 +221,7 @@ namespace MonoDevelop.CodeMetrics lock(Enums) { foreach(var typeArg in enm.TypeParameters) { - foreach(var constraint in typeArg.GetConstraints (enm.ProjectContent)) { + foreach(var constraint in typeArg.DirectBaseTypes) { key.Append(constraint.ToString ()); } } @@ -236,7 +236,7 @@ namespace MonoDevelop.CodeMetrics lock(Delegates) { foreach(var typeArg in dlgte.TypeParameters) { - foreach(var constraint in typeArg.GetConstraints (dlgte.ProjectContent)) { + foreach(var constraint in typeArg.DirectBaseTypes) { key.Append(constraint.ToString ()); } } |