You've already forked linux-packaging-mono
Imported Upstream version 5.18.0.142
Former-commit-id: 7467d4b717762eeaf652d77f1486dd11ffb1ff1f
This commit is contained in:
parent
e52655b4dc
commit
0abdbe5a7d
@@ -32,16 +32,11 @@ using System.IO;
|
||||
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace GuiCompare {
|
||||
namespace Mono.ApiTools {
|
||||
|
||||
public class AssemblyResolver : DefaultAssemblyResolver {
|
||||
class AssemblyResolver : DefaultAssemblyResolver {
|
||||
|
||||
public AssemblyDefinition ResolveFile (string file)
|
||||
{
|
||||
return ProcessFile (file);
|
||||
}
|
||||
|
||||
AssemblyDefinition ProcessFile (string file)
|
||||
{
|
||||
AddSearchDirectory (Path.GetDirectoryName (file));
|
||||
var assembly = AssemblyDefinition.ReadAssembly (file, new ReaderParameters { AssemblyResolver = this, InMemory = true });
|
||||
@@ -49,5 +44,13 @@ namespace GuiCompare {
|
||||
|
||||
return assembly;
|
||||
}
|
||||
|
||||
public AssemblyDefinition ResolveStream (Stream stream)
|
||||
{
|
||||
var assembly = AssemblyDefinition.ReadAssembly (stream, new ReaderParameters { AssemblyResolver = this, InMemory = true });
|
||||
RegisterAssembly (assembly);
|
||||
|
||||
return assembly;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,32 +3,57 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Mono.Cecil;
|
||||
|
||||
using GuiCompare;
|
||||
namespace Mono.ApiTools {
|
||||
|
||||
namespace CorCompare {
|
||||
class TypeHelper {
|
||||
|
||||
static class TypeHelper {
|
||||
public TypeHelper (bool ignoreResolutionErrors, bool ignoreInheritedInterfaces)
|
||||
{
|
||||
IgnoreResolutionErrors = ignoreResolutionErrors;
|
||||
IgnoreInheritedInterfaces = ignoreInheritedInterfaces;
|
||||
}
|
||||
|
||||
public static AssemblyResolver Resolver = new AssemblyResolver ();
|
||||
public bool IgnoreResolutionErrors { get; }
|
||||
|
||||
internal static bool IsPublic (TypeReference typeref)
|
||||
public bool IgnoreInheritedInterfaces { get; }
|
||||
|
||||
public AssemblyResolver Resolver { get; } = new AssemblyResolver();
|
||||
|
||||
internal bool TryResolve (CustomAttribute attribute)
|
||||
{
|
||||
if (attribute == null)
|
||||
throw new ArgumentNullException (nameof (attribute));
|
||||
|
||||
try {
|
||||
var has = attribute.HasProperties;
|
||||
return true;
|
||||
} catch (AssemblyResolutionException) when (IgnoreResolutionErrors) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsPublic (TypeReference typeref)
|
||||
{
|
||||
if (typeref == null)
|
||||
throw new ArgumentNullException ("typeref");
|
||||
|
||||
TypeDefinition td = typeref.Resolve ();
|
||||
if (td == null)
|
||||
return false;
|
||||
try {
|
||||
var td = typeref.Resolve ();
|
||||
if (td == null)
|
||||
return false;
|
||||
|
||||
return td.IsPublic;
|
||||
return td.IsPublic || (td.IsNestedPublic && IsPublic (td.DeclaringType));
|
||||
} catch (AssemblyResolutionException) when (IgnoreResolutionErrors) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool IsDelegate (TypeReference typeref)
|
||||
internal bool IsDelegate (TypeReference typeref)
|
||||
{
|
||||
return IsDerivedFrom (typeref, "System.MulticastDelegate");
|
||||
}
|
||||
|
||||
internal static bool IsDerivedFrom (TypeReference type, string derivedFrom)
|
||||
internal bool IsDerivedFrom (TypeReference type, string derivedFrom)
|
||||
{
|
||||
bool first = true;
|
||||
foreach (var def in WalkHierarchy (type)) {
|
||||
@@ -44,52 +69,71 @@ namespace CorCompare {
|
||||
return false;
|
||||
}
|
||||
|
||||
internal static IEnumerable<TypeDefinition> WalkHierarchy (TypeReference type)
|
||||
internal IEnumerable<TypeDefinition> WalkHierarchy (TypeReference type)
|
||||
{
|
||||
for (var def = type.Resolve (); def != null; def = GetBaseType (def))
|
||||
yield return def;
|
||||
}
|
||||
|
||||
internal static IEnumerable<TypeReference> GetInterfaces (TypeReference type)
|
||||
internal IEnumerable<TypeReference> GetInterfaces (TypeReference type)
|
||||
{
|
||||
var ifaces = new Dictionary<string, TypeReference> ();
|
||||
|
||||
foreach (var def in WalkHierarchy (type))
|
||||
foreach (var def in WalkHierarchy (type)) {
|
||||
foreach (var iface in def.Interfaces)
|
||||
ifaces [iface.InterfaceType.FullName] = iface.InterfaceType;
|
||||
if (IgnoreInheritedInterfaces)
|
||||
break;
|
||||
}
|
||||
|
||||
return ifaces.Values;
|
||||
}
|
||||
|
||||
internal static TypeDefinition GetBaseType (TypeDefinition child)
|
||||
internal TypeDefinition GetBaseType (TypeDefinition child)
|
||||
{
|
||||
if (child.BaseType == null)
|
||||
return null;
|
||||
|
||||
return child.BaseType.Resolve ();
|
||||
try {
|
||||
return child.BaseType.Resolve ();
|
||||
} catch (AssemblyResolutionException) when (IgnoreResolutionErrors) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool IsPublic (CustomAttribute att)
|
||||
internal MethodDefinition GetMethod (MethodReference method)
|
||||
{
|
||||
if (method == null)
|
||||
throw new ArgumentNullException (nameof (method));
|
||||
|
||||
try {
|
||||
return method.Resolve ();
|
||||
} catch (AssemblyResolutionException) when (IgnoreResolutionErrors) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsPublic (CustomAttribute att)
|
||||
{
|
||||
return IsPublic (att.AttributeType);
|
||||
}
|
||||
|
||||
internal static string GetFullName (CustomAttribute att)
|
||||
internal string GetFullName (CustomAttribute att)
|
||||
{
|
||||
return att.AttributeType.FullName;
|
||||
}
|
||||
|
||||
internal static TypeDefinition GetTypeDefinition (CustomAttribute att)
|
||||
internal TypeDefinition GetTypeDefinition (CustomAttribute att)
|
||||
{
|
||||
return att.AttributeType.Resolve ();
|
||||
}
|
||||
|
||||
static bool IsOverride (MethodDefinition method)
|
||||
bool IsOverride (MethodDefinition method)
|
||||
{
|
||||
return method.IsVirtual && !method.IsNewSlot;
|
||||
}
|
||||
|
||||
public static MethodDefinition GetBaseMethodInTypeHierarchy (MethodDefinition method)
|
||||
public MethodDefinition GetBaseMethodInTypeHierarchy (MethodDefinition method)
|
||||
{
|
||||
if (!IsOverride (method))
|
||||
return method;
|
||||
@@ -106,7 +150,7 @@ namespace CorCompare {
|
||||
return method;
|
||||
}
|
||||
|
||||
static MethodDefinition TryMatchMethod (TypeDefinition type, MethodDefinition method)
|
||||
MethodDefinition TryMatchMethod (TypeDefinition type, MethodDefinition method)
|
||||
{
|
||||
if (!type.HasMethods)
|
||||
return null;
|
||||
@@ -118,7 +162,7 @@ namespace CorCompare {
|
||||
return null;
|
||||
}
|
||||
|
||||
static bool MethodMatch (MethodDefinition candidate, MethodDefinition method)
|
||||
bool MethodMatch (MethodDefinition candidate, MethodDefinition method)
|
||||
{
|
||||
if (!candidate.IsVirtual)
|
||||
return false;
|
||||
@@ -139,7 +183,7 @@ namespace CorCompare {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TypeMatch (IModifierType a, IModifierType b)
|
||||
public bool TypeMatch (IModifierType a, IModifierType b)
|
||||
{
|
||||
if (!TypeMatch (a.ModifierType, b.ModifierType))
|
||||
return false;
|
||||
@@ -147,7 +191,7 @@ namespace CorCompare {
|
||||
return TypeMatch (a.ElementType, b.ElementType);
|
||||
}
|
||||
|
||||
public static bool TypeMatch (TypeSpecification a, TypeSpecification b)
|
||||
public bool TypeMatch (TypeSpecification a, TypeSpecification b)
|
||||
{
|
||||
if (a is GenericInstanceType)
|
||||
return TypeMatch ((GenericInstanceType) a, (GenericInstanceType) b);
|
||||
@@ -158,7 +202,7 @@ namespace CorCompare {
|
||||
return TypeMatch (a.ElementType, b.ElementType);
|
||||
}
|
||||
|
||||
public static bool TypeMatch (GenericInstanceType a, GenericInstanceType b)
|
||||
public bool TypeMatch (GenericInstanceType a, GenericInstanceType b)
|
||||
{
|
||||
if (!TypeMatch (a.ElementType, b.ElementType))
|
||||
return false;
|
||||
@@ -176,7 +220,7 @@ namespace CorCompare {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TypeMatch (TypeReference a, TypeReference b)
|
||||
public bool TypeMatch (TypeReference a, TypeReference b)
|
||||
{
|
||||
if (a is GenericParameter)
|
||||
return true;
|
||||
|
@@ -11,9 +11,9 @@ using System.Globalization;
|
||||
using System.Collections;
|
||||
using System.Xml;
|
||||
|
||||
namespace CorCompare {
|
||||
namespace Mono.ApiTools {
|
||||
|
||||
public class WellFormedXmlWriter : DefaultXmlWriter
|
||||
class WellFormedXmlWriter : DefaultXmlWriter
|
||||
{
|
||||
public static bool IsInvalid (int ch)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ namespace CorCompare {
|
||||
|
||||
}
|
||||
|
||||
public class DefaultXmlWriter : XmlWriter
|
||||
class DefaultXmlWriter : XmlWriter
|
||||
{
|
||||
XmlWriter writer;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user