5 changed files with 194 additions and 313 deletions
@ -0,0 +1,137 @@
@@ -0,0 +1,137 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 25.12.2011 |
||||
* Time: 19:07 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.CodeQualityAnalysis.Utility |
||||
{ |
||||
/// <summary>
|
||||
/// Description of testclass.
|
||||
/// </summary>
|
||||
public class QueryMainModule |
||||
{ |
||||
public QueryMainModule(Module mainModule) |
||||
{ |
||||
MainModule = mainModule; |
||||
} |
||||
|
||||
public Module MainModule {get; private set;} |
||||
|
||||
private List <INode> QueryForMethod() |
||||
{ |
||||
IEnumerable<INode> query = new List<INode>(); |
||||
query = from ns in MainModule.Namespaces |
||||
from type in ns.Types |
||||
from method in type.Methods |
||||
select method; |
||||
return query.ToList(); |
||||
} |
||||
|
||||
|
||||
public List<ItemWithAction> NameSpaceList() |
||||
{ |
||||
List<ItemWithAction> items = new List<ItemWithAction>(); |
||||
items.Add(new ItemWithAction() |
||||
{ |
||||
Description = "# of Methods", |
||||
Metrics = Metrics.CyclomaticComplexity.ToString(), |
||||
Action = ExecuteNotImplemented |
||||
}); |
||||
items.Add(new ItemWithAction() |
||||
{ |
||||
Description = "# of Fields", |
||||
Metrics = Metrics.Variables.ToString(), |
||||
Action = ExecuteNotImplemented |
||||
}); |
||||
items.Add(new ItemWithAction() |
||||
{ |
||||
Description = "# of Types", |
||||
Metrics = Metrics.Variables.ToString(), |
||||
Action = ExecuteNotImplemented |
||||
}); |
||||
|
||||
items.Add(new ItemWithAction() |
||||
{ |
||||
Description = "# of Namespaces", |
||||
Metrics = Metrics.Variables.ToString(), |
||||
Action = ExecuteNotImplemented |
||||
}); |
||||
return items; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
public List<ItemWithAction> MethodList() |
||||
{ |
||||
List<ItemWithAction> items = new List<ItemWithAction>(); |
||||
items.Add(new ItemWithAction() |
||||
{ |
||||
Description = "# of IL Instructions", |
||||
Metrics = "Instructions.Count", |
||||
Action = ExecuteMethodILInstructions |
||||
}); |
||||
items.Add(new ItemWithAction() |
||||
{ |
||||
Description = "Cyclomatic Complexity", |
||||
Metrics = Metrics.CyclomaticComplexity.ToString(), |
||||
Action = ExecuteMethodComplexity |
||||
}); |
||||
items.Add(new ItemWithAction() |
||||
{ |
||||
Description = "Variables", |
||||
Metrics = Metrics.Variables.ToString(), |
||||
Action = ExecuteMethodVariables |
||||
}); |
||||
return items; |
||||
} |
||||
|
||||
private List<INode> ExecuteNotImplemented() |
||||
{ |
||||
MessageService.ShowMessage("Not Implemented yet","CodeQualityAnalysis"); |
||||
return null; |
||||
} |
||||
|
||||
|
||||
private List<INode> ExecuteMethodILInstructions() |
||||
{ |
||||
var intermediate = QueryForMethod().Cast<Method>().ToList(); |
||||
var filtered = from method in intermediate |
||||
where method.Instructions.Count > 0 |
||||
select method; |
||||
return filtered.Cast<INode>().ToList(); |
||||
} |
||||
|
||||
|
||||
private List<INode> ExecuteMethodComplexity () |
||||
{ |
||||
var intermediate = QueryForMethod().Cast<Method>().ToList(); |
||||
var filtered = from method in intermediate |
||||
where method.CyclomaticComplexity > 0 |
||||
select method; |
||||
return filtered.Cast<INode>().ToList(); |
||||
} |
||||
|
||||
|
||||
private List<INode> ExecuteMethodVariables () |
||||
{ |
||||
var intermediate = QueryForMethod().Cast<Method>().ToList(); |
||||
// eliminate 0-values
|
||||
var filtered = from method in intermediate |
||||
where method.Variables > 0 |
||||
select method; |
||||
|
||||
return filtered.Cast<INode>().ToList(); |
||||
} |
||||
} |
||||
} |
@ -1,87 +0,0 @@
@@ -1,87 +0,0 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 25.12.2011 |
||||
* Time: 19:07 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Linq; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
|
||||
namespace ICSharpCode.CodeQualityAnalysis.Utility |
||||
{ |
||||
/// <summary>
|
||||
/// Description of testclass.
|
||||
/// </summary>
|
||||
public class testclass |
||||
{ |
||||
public testclass(Module mainModule) |
||||
{ |
||||
MainModule = mainModule; |
||||
} |
||||
|
||||
public Module MainModule {get; private set;} |
||||
|
||||
public ObservableCollection <INode> QueryMethod() |
||||
{ |
||||
IEnumerable<INode> list = new List<INode>(); |
||||
list = from ns in MainModule.Namespaces |
||||
from type in ns.Types |
||||
from method in type.Methods |
||||
select method; |
||||
return new ObservableCollection <INode>(list); |
||||
} |
||||
|
||||
public List<ItemWithAction> MethodList() |
||||
{ |
||||
List<ItemWithAction> itemsWithCommand = new List<ItemWithAction>(); |
||||
itemsWithCommand.Add(new ItemWithAction() |
||||
{ |
||||
Description = "IL Instructions", |
||||
Action = ExecuteMerhodIlInstructions |
||||
}); |
||||
itemsWithCommand.Add(new ItemWithAction() |
||||
{ |
||||
Description = "Cyclomatic Complexity", |
||||
Action = ExecuteMethodComplexity |
||||
}); |
||||
itemsWithCommand.Add(new ItemWithAction() |
||||
{ |
||||
Description = "Variables", |
||||
Action = ExecuteMethodVariables |
||||
}); |
||||
return itemsWithCommand; |
||||
} |
||||
|
||||
|
||||
private void ExecuteMerhodIlInstructions() |
||||
{ |
||||
// var t = new testclass(MainModule);
|
||||
// TreeValueProperty = "Instructions.Count";
|
||||
// Nodes = t.QueryMethod();
|
||||
} |
||||
|
||||
private void ExecuteMethodComplexity () |
||||
{ |
||||
// var t = new testclass(MainModule);
|
||||
// TreeValueProperty = Metrics.CyclomaticComplexity.ToString();
|
||||
// var tt = t.QueryMethod();
|
||||
// foreach (var element in tt) {
|
||||
// var m = element as Method;
|
||||
// Console.WriteLine("{0} - {1}",m.Name,m.CyclomaticComplexity);
|
||||
// }
|
||||
// Nodes = t.QueryMethod();
|
||||
} |
||||
|
||||
|
||||
private void ExecuteMethodVariables () |
||||
{ |
||||
// var t = new testclass(MainModule);
|
||||
// TreeValueProperty = Metrics.Variables.ToString();
|
||||
// Nodes = t.QueryMethod();
|
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue