Skip to content

Commit

Permalink
Stop mixed-mode from derailing pinvoke detection
Browse files Browse the repository at this point in the history
The mixed-mode example project displays a weird case where a pinvoke is
detected but no further information is available (PInvokeInfo == null).
Marking these anomalies as "skipped".
  • Loading branch information
pearswj committed Feb 26, 2016
1 parent 4a83eb7 commit 5ff97ed
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/Compat/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -269,29 +269,23 @@ static IMetadataScope GetOperandScope(object operand)
/// <returns>True if the operand is a PInvoke, otherwise false.</returns>
static bool IsPInvoke(object operand, out ModuleReference nativeLib)
{
nativeLib = null;
// try to cast operand to method definition and check for PInvoke
var mdef = operand as MethodDefinition;
if (mdef != null)
{
if (mdef.IsPInvokeImpl)
{
logger.Debug("Is PInvoke? {0}", true);
nativeLib = mdef.PInvokeInfo.Module;
logger.Debug("Native library: {0}", nativeLib.Name);
if (mdef.PInvokeInfo != null)
{
nativeLib = mdef.PInvokeInfo.Module;
logger.Debug("Native library: {0}", nativeLib.Name);
}
return true;
}
}
// I don't think testing fields is necessary...
//else
//{
// var fdef = operand as FieldDefinition;
// if (fdef != null)
// {
// return fdef.IsPInvokeImpl;
// }
//}

nativeLib = null;
return false;
}

Expand Down

0 comments on commit 5ff97ed

Please sign in to comment.