Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions Confuser.Core/ConfuserEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,10 @@ static void Inspection(ConfuserContext context) {
context.Logger.Info("Resolving dependencies...");
foreach (var dependency in context.Modules
.SelectMany(module => module.GetAssemblyRefs().Select(asmRef => Tuple.Create(asmRef, module)))) {
try {
context.Resolver.ResolveThrow(dependency.Item1, dependency.Item2);
}
catch (AssemblyResolveException ex) {
context.Logger.ErrorException("Failed to resolve dependency of '" + dependency.Item2.Name + "'.", ex);
throw new ConfuserException(ex);
}
var resolved = context.Resolver.Resolve(dependency.Item1, dependency.Item2);
if (resolved == null)
context.Logger.WarnFormat("Failed to resolve dependency '{0}' of '{1}'. Some protections may not work correctly.",
dependency.Item1.FullName, dependency.Item2.Name);
}

context.Logger.Debug("Checking Strong Name...");
Expand Down
44 changes: 16 additions & 28 deletions Confuser.Core/DnlibUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,12 @@ public static bool IsDelegate(this TypeDef type) {
/// <param name="baseType">The full name of base type.</param>
/// <returns><c>true</c> if the specified type is inherited from a base type; otherwise, <c>false</c>.</returns>
public static bool InheritsFromCorlib(this TypeDef type, string baseType) {
if (type.BaseType == null)
return false;

TypeDef bas = type;
do {
bas = bas.BaseType.ResolveTypeDefThrow();
var bas = type.BaseType?.ResolveTypeDef();
while (bas != null && bas.DefinitionAssembly.IsCorLib()) {
if (bas.ReflectionFullName == baseType)
return true;
} while (bas.BaseType != null && bas.BaseType.DefinitionAssembly.IsCorLib());
bas = bas.BaseType?.ResolveTypeDef();
}
return false;
}

Expand All @@ -228,15 +225,12 @@ public static bool InheritsFromCorlib(this TypeDef type, string baseType) {
/// <param name="baseType">The full name of base type.</param>
/// <returns><c>true</c> if the specified type is inherited from a base type; otherwise, <c>false</c>.</returns>
public static bool InheritsFrom(this TypeDef type, string baseType) {
if (type.BaseType == null)
return false;

TypeDef bas = type;
do {
bas = bas.BaseType.ResolveTypeDefThrow();
var bas = type.BaseType?.ResolveTypeDef();
while (bas != null) {
if (bas.ReflectionFullName == baseType)
return true;
} while (bas.BaseType != null);
bas = bas.BaseType?.ResolveTypeDef();
}
return false;
}

Expand All @@ -247,18 +241,12 @@ public static bool InheritsFrom(this TypeDef type, string baseType) {
/// <param name="fullName">The full name of the type of interface.</param>
/// <returns><c>true</c> if the specified type implements the interface; otherwise, <c>false</c>.</returns>
public static bool Implements(this TypeDef type, string fullName) {
do {
foreach (InterfaceImpl iface in type.Interfaces) {
if (iface.Interface.ReflectionFullName == fullName)
return true;
}

if (type.BaseType == null)
return false;

type = type.BaseType.ResolveTypeDefThrow();
} while (type != null);
throw new UnreachableException();
while (type != null) {
if (type.Interfaces.Any(iface => iface.Interface.ReflectionFullName == fullName))
return true;
type = type.BaseType?.ResolveTypeDef();
}
return false;
}

/// <summary>
Expand Down Expand Up @@ -451,8 +439,8 @@ public static bool IsImplicitImplementedInterfaceMember(this MethodDef method) {

if (method.IsPublic && method.IsNewSlot) {
foreach (var iFace in method.DeclaringType.Interfaces) {
var iFaceDef = iFace.Interface.ResolveTypeDefThrow();
if (iFaceDef.FindMethod(method.Name, (MethodSig)method.Signature) != null)
var iFaceDef = iFace.Interface.ResolveTypeDef();
if (iFaceDef != null && iFaceDef.FindMethod(method.Name, (MethodSig)method.Signature) != null)
return true;
}
}
Expand Down
Loading