Throw if PInvokeInfo is null. The type was probably removed.

This commit is contained in:
de4dot 2011-10-31 00:18:11 +01:00
parent 6b04c23036
commit 5185dc8364

View File

@ -877,6 +877,8 @@ namespace de4dot.renamer {
foreach (var method in methods.getAll())
methodNames[method.NewName] = true;
if (methodDef.MethodDefinition.PInvokeInfo == null)
throw new ApplicationException(string.Format("PInvokeInfo is null: A type was probably removed but still referenced by the code."));
var entryPoint = methodDef.MethodDefinition.PInvokeInfo.EntryPoint;
if (Regex.IsMatch(entryPoint, @"^#\d+$"))
entryPoint = DotNetUtils.getDllName(methodDef.MethodDefinition.PInvokeInfo.Module.Name) + "_" + entryPoint.Substring(1);