зеркало из https://github.com/mono/moma.git
MoMA Updated to Cecil 0.9.6.4
This commit is contained in:
Родитель
838da0c08f
Коммит
531362dcac
|
@ -28,6 +28,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using System.Linq;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
|
||||
|
@ -257,7 +258,7 @@ namespace MoMA.Analyzer
|
|||
AssemblyDefinition ad = AssemblyDefinition.ReadAssembly (assembly);
|
||||
|
||||
assembly_version = ad.Name.Version;
|
||||
AssemblyRuntime = ad.Runtime.ToString ();
|
||||
AssemblyRuntime = ad.Modules.FirstOrDefault()?.Runtime.ToString () ?? "";
|
||||
assembly_name = Path.GetFileName (assembly);
|
||||
|
||||
foreach (TypeDefinition type in ad.MainModule.Types) {
|
||||
|
@ -286,7 +287,7 @@ namespace MoMA.Analyzer
|
|||
}
|
||||
|
||||
// Check every constructor for calls that match our issues lists
|
||||
foreach (MethodDefinition method in type.Constructors) {
|
||||
foreach (MethodDefinition method in type.Methods.Where(m => m.IsConstructor)) {
|
||||
if (method.Body != null) {
|
||||
foreach (Instruction i in method.Body.Instructions) {
|
||||
if (i.OpCode == OpCodes.Call || i.OpCode == OpCodes.Callvirt || i.OpCode == OpCodes.Calli || i.OpCode == OpCodes.Ldftn || i.OpCode == OpCodes.Ldvirtftn || i.OpCode == OpCodes.Newobj || i.OpCode == OpCodes.Initobj) {
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace MoMA.Analyzer
|
|||
final_parameters += (ConvertType (p.ParameterType.ToString ()) + ", ");
|
||||
|
||||
function_name = md.Name;
|
||||
return_type = ConvertType (md.ReturnType.ReturnType.FullName);
|
||||
return_type = ConvertType (md.ReturnType.FullName);
|
||||
|
||||
if (final_parameters.Length > 0)
|
||||
final_parameters = final_parameters.Substring (0, final_parameters.Length - 2);
|
||||
|
|
|
@ -23,7 +23,10 @@
|
|||
// Jonathan Pobst monkey@jpobst.com
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
|
||||
|
@ -51,9 +54,9 @@ namespace MoMA.Analyzer
|
|||
foreach (CustomAttribute ca in property.CustomAttributes) {
|
||||
if (IsReportableMonoTODO (ca.Constructor.DeclaringType.ToString ())) {
|
||||
if (property.GetMethod != null && IsMethodVisible (property.GetMethod))
|
||||
monoTodoMethods[property.GetMethod.ToString ()] = new Method (property.GetMethod.ToString (), ca.ConstructorParameters.Count > 0 ? ca.ConstructorParameters[0].ToString ().Replace ('\n', ' ') : string.Empty);
|
||||
monoTodoMethods[property.GetMethod.ToString ()] = new Method (property.GetMethod.ToString (), ca.Constructor.Parameters.Count > 0 ? ca.Constructor.Parameters[0].ToString ().Replace ('\n', ' ') : string.Empty);
|
||||
if (property.SetMethod != null && IsMethodVisible (property.SetMethod))
|
||||
monoTodoMethods[property.SetMethod.ToString ()] = new Method (property.SetMethod.ToString (), ca.ConstructorParameters.Count > 0 ? ca.ConstructorParameters[0].ToString ().Replace ('\n', ' ') : string.Empty);
|
||||
monoTodoMethods[property.SetMethod.ToString ()] = new Method (property.SetMethod.ToString (), ca.Constructor.Parameters.Count > 0 ? ca.Constructor.Parameters[0].ToString ().Replace ('\n', ' ') : string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +75,7 @@ namespace MoMA.Analyzer
|
|||
if (monoTodoMethods != null)
|
||||
foreach (CustomAttribute ca in method.CustomAttributes)
|
||||
if (IsReportableMonoTODO (ca.Constructor.DeclaringType.ToString ()))
|
||||
monoTodoMethods[method.ToString ()] = new Method (method.ToString (), ca.ConstructorParameters.Count > 0 ? ca.ConstructorParameters[0].ToString ().Replace ('\n', ' ') : string.Empty);
|
||||
monoTodoMethods[method.ToString ()] = new Method (method.ToString (), ca.Constructor.Parameters.Count > 0 ? ca.Constructor.Parameters[0].ToString ().Replace ('\n', ' ') : string.Empty);
|
||||
|
||||
// If adding methods that throw NotImplementedException, look for those
|
||||
if (throwsNotImplementedMethods != null && ThrowsNotImplementedException (method))
|
||||
|
@ -80,7 +83,7 @@ namespace MoMA.Analyzer
|
|||
}
|
||||
|
||||
//Gets all constructors of the current type
|
||||
foreach (MethodDefinition method in type.Constructors) {
|
||||
foreach (MethodDefinition method in type.Methods.Where(m => m.IsConstructor)) {
|
||||
// We only want Public and Protected methods
|
||||
if (!IsMethodVisible (method))
|
||||
continue;
|
||||
|
@ -93,7 +96,7 @@ namespace MoMA.Analyzer
|
|||
if (monoTodoMethods != null)
|
||||
foreach (CustomAttribute ca in method.CustomAttributes)
|
||||
if (IsReportableMonoTODO (ca.Constructor.DeclaringType.ToString ()))
|
||||
monoTodoMethods[method.ToString ()] = new Method (method.ToString (), ca.ConstructorParameters.Count > 0 ? ca.ConstructorParameters[0].ToString ().Replace ('\n', ' ') : string.Empty);
|
||||
monoTodoMethods[method.ToString ()] = new Method (method.ToString (), ca.Constructor.Parameters.Count > 0 ? ca.Constructor.Parameters[0].ToString ().Replace ('\n', ' ') : string.Empty);
|
||||
|
||||
// If adding methods that throw NotImplementedException, look for those
|
||||
if (throwsNotImplementedMethods != null && ThrowsNotImplementedException (method))
|
||||
|
@ -132,10 +135,34 @@ namespace MoMA.Analyzer
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public class TypeDefinitionCache: KeyedCollection<string, TypeDefinition> {
|
||||
protected override string GetKeyForItem(TypeDefinition item) => item.FullName;
|
||||
|
||||
public void Add(AssemblyDefinition a) {
|
||||
var defs = a.Modules.SelectMany(m => m.Types);
|
||||
foreach (var def in defs) Add(def);
|
||||
}
|
||||
|
||||
public TypeDefinition Find(TypeReference reference) {
|
||||
TypeDefinition def = null;
|
||||
if (Dictionary != null) {
|
||||
if (!Dictionary.TryGetValue(reference.FullName, out def)) Add(reference.Module.Assembly);
|
||||
if (!Dictionary.TryGetValue(reference.FullName, out def)) throw new NotSupportedException();
|
||||
} else {
|
||||
if (!Contains(reference.FullName)) Add(reference.Module.Assembly);
|
||||
if (!Contains(reference.FullName)) throw new NotSupportedException();
|
||||
def = this[reference.FullName];
|
||||
}
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
static TypeDefinitionCache Cache = new TypeDefinitionCache();
|
||||
private static TypeDefinition TypeReferenceToDefinition (TypeReference type)
|
||||
{
|
||||
return type.Module.Types[type.FullName];
|
||||
if (type.Module.Types.Count < 10) return type.Module.Types.FirstOrDefault(def => def.FullName == type.FullName);
|
||||
else return Cache.Find(type);
|
||||
}
|
||||
|
||||
// Is this attribute a MonoTODO that we want to report in MoMA?
|
||||
|
|
|
@ -37,19 +37,19 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net40\Mono.Cecil.dll</HintPath>
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net40\Mono.Cecil.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net40\Mono.Cecil.Mdb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net40\Mono.Cecil.Pdb.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net40\Mono.Cecil.Rocks.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net40" />
|
||||
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net40" />
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
|
||||
</packages>
|
Загрузка…
Ссылка в новой задаче