public static bool ShouldImportMethod(this PEModule module, TypeDefinitionHandle typeDef, MethodDefinitionHandle methodDef, MetadataImportOptions importOptions) { try { var flags = module.GetMethodDefFlagsOrThrow(methodDef); // If the method is virtual, it must be accessible, although // it may be an explicit (private) interface implementation. // Otherwise, we need to check the accessibility. if ((flags & MethodAttributes.Virtual) == 0 && !acceptBasedOnAccessibility(importOptions, flags) && ((flags & MethodAttributes.Static) == 0 || !isMethodImpl(typeDef, methodDef))) { return(false); } } catch (BadImageFormatException) { } try { // As in the native C# compiler (see IMPORTER::ImportMethod), drop any method prefixed // with "_VtblGap". They should be impossible to call/implement/etc. // BREAK: The native VB compiler does not drop such methods, but it produces unverifiable // code when they are called, so the break is acceptable. // TODO: Keep some record of vtable gaps (DevDiv #17472). var name = module.GetMethodDefNameOrThrow(methodDef); return(!name.StartsWith(VTableGapMethodNamePrefix, StringComparison.Ordinal)); } catch (BadImageFormatException) { return(true); }