public bool CompareMethodSignatures(RuntimeSignature signature1, RuntimeSignature signature2) { if (signature1.IsNativeLayoutSignature && signature2.IsNativeLayoutSignature) { if (signature1.StructuralEquals(signature2)) { return(true); } NativeFormatModuleInfo module1 = ModuleList.GetModuleInfoByHandle(new TypeManagerHandle(signature1.ModuleHandle)); NativeReader reader1 = GetNativeLayoutInfoReader(signature1); NativeParser parser1 = new NativeParser(reader1, signature1.NativeLayoutOffset); NativeFormatModuleInfo module2 = ModuleList.GetModuleInfoByHandle(new TypeManagerHandle(signature2.ModuleHandle)); NativeReader reader2 = GetNativeLayoutInfoReader(signature2); NativeParser parser2 = new NativeParser(reader2, signature2.NativeLayoutOffset); return(CompareMethodSigs(parser1, module1, parser2, module2)); } else if (signature1.IsNativeLayoutSignature) { int token = signature2.Token; MetadataReader metadataReader = ModuleList.Instance.GetMetadataReaderForModule(new TypeManagerHandle(signature2.ModuleHandle)); MethodSignatureComparer comparer = new MethodSignatureComparer(metadataReader, token.AsHandle().ToMethodHandle(metadataReader)); return(comparer.IsMatchingNativeLayoutMethodSignature(signature1)); } else if (signature2.IsNativeLayoutSignature) { int token = signature1.Token; MetadataReader metadataReader = ModuleList.Instance.GetMetadataReaderForModule(new TypeManagerHandle(signature1.ModuleHandle)); MethodSignatureComparer comparer = new MethodSignatureComparer(metadataReader, token.AsHandle().ToMethodHandle(metadataReader)); return(comparer.IsMatchingNativeLayoutMethodSignature(signature2)); } else { // For now, RuntimeSignatures are only used to compare for method signature equality (along with their Name) // So we can implement this with the simple equals check if (signature1.Token != signature2.Token) { return(false); } if (signature1.ModuleHandle != signature2.ModuleHandle) { return(false); } return(true); } }
public bool Equals(CallConversionInfo other) { if (_registrationKind != other._registrationKind) { return(false); } if (_thunkKind != other._thunkKind) { return(false); } if (_targetFunctionPointer != other._targetFunctionPointer) { return(false); } if (_instantiatingArg != other._instantiatingArg) { return(false); } switch (_registrationKind) { case CallConversionInfoRegistrationKind.UsesMethodSignatureAndGenericArgs: { return(_methodSignature.StructuralEquals(other._methodSignature) && ArraysAreEqual(_typeArgs, other._typeArgs) && ArraysAreEqual(_methodArgs, other._methodArgs)); } case CallConversionInfoRegistrationKind.UsesArgIteratorData: { return(_argIteratorData.Equals(other._argIteratorData) && ArraysAreEqual(_paramsByRefForced, other._paramsByRefForced)); } } Debug.Fail("UNREACHABLE"); return(false); }