private static unsafe bool FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, ref Assembly lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, bool mustBeInheritable, object[] attributes, IList derivedAttributes, out RuntimeType attributeType, out IRuntimeMethodInfo ctor, out bool ctorHasParameters, out bool isVarArg) { ctor = null; attributeType = null; ctorHasParameters = false; isVarArg = false; IntPtr ptr1 = (IntPtr)(((void *)caRecord.blob.Signature) + caRecord.blob.Length); attributeType = decoratedModule.ResolveType(scope.GetParentToken((int)caRecord.tkCtor), null, null) as RuntimeType; if (!attributeFilterType.IsAssignableFrom(attributeType)) { return(false); } if (!AttributeUsageCheck(attributeType, mustBeInheritable, attributes, derivedAttributes)) { return(false); } RuntimeAssembly targetAssembly = (RuntimeAssembly)attributeType.Assembly; RuntimeAssembly assembly = (RuntimeAssembly)decoratedModule.Assembly; if ((targetAssembly != lastAptcaOkAssembly) && !RuntimeAssembly.AptcaCheck(targetAssembly, assembly)) { return(false); } lastAptcaOkAssembly = assembly; ConstArray methodSignature = scope.GetMethodSignature(caRecord.tkCtor); isVarArg = (methodSignature[0] & 5) != 0; ctorHasParameters = methodSignature[1] != 0; if (ctorHasParameters) { ctor = ModuleHandle.ResolveMethodHandleInternal(decoratedModule.GetNativeHandle(), (int)caRecord.tkCtor); } else { ctor = attributeType.GetTypeHandleInternal().GetDefaultConstructor(); if ((ctor == null) && !attributeType.IsValueType) { throw new MissingMethodException(".ctor"); } } if (ctor == null) { if (!attributeType.IsVisible && !attributeType.TypeHandle.IsVisibleFromModule(decoratedModule)) { return(false); } return(true); } if (RuntimeMethodHandle.IsVisibleFromModule(ctor, decoratedModule)) { return(true); } MetadataToken token = new MetadataToken(); if (decoratedToken.IsParamDef) { token = new MetadataToken(scope.GetParentToken((int)decoratedToken)); token = new MetadataToken(scope.GetParentToken((int)token)); } else if ((decoratedToken.IsMethodDef || decoratedToken.IsProperty) || (decoratedToken.IsEvent || decoratedToken.IsFieldDef)) { token = new MetadataToken(scope.GetParentToken((int)decoratedToken)); } else if (decoratedToken.IsTypeDef) { token = decoratedToken; } return(token.IsTypeDef && RuntimeMethodHandle.IsVisibleFromType(ctor, decoratedModule.ModuleHandle.ResolveTypeHandle((int)token))); }