// Assumes declaring type is visible and is either public or internal // Assumes method type args (if any) are visible internal static bool IsProtectedVisibleTo(MethodInfo method, Type derivedType, XamlSchemaContext schemaContext) { if (derivedType == null) { return(false); } // Note: this doesn't handle the case of method.IsAssembly, because callers should use // IsInternalVisibleTo for those cases. if (!derivedType.Equals(method.DeclaringType) && !derivedType.IsSubclassOf(method.DeclaringType)) { return(false); } if (method.IsFamily || method.IsFamilyOrAssembly) { return(true); } if (method.IsFamilyAndAssembly) { if (TypeReflector.IsInternal(method.DeclaringType)) { // We've already done an internals visibility check for the declaring type return(true); } return(schemaContext.AreInternalsVisibleTo( method.DeclaringType.Assembly, derivedType.Assembly)); } return(false); }
// Assumes declaring type is visible and is either public or internal // Assumes method type args (if any) are visible internal static bool IsInternalVisibleTo(MethodInfo method, Assembly accessingAssembly, XamlSchemaContext schemaContext) { if (accessingAssembly == null) { return(false); } if (method.IsAssembly || method.IsFamilyOrAssembly) { if (TypeReflector.IsInternal(method.DeclaringType)) { // We've already done an internals visibility check for the declaring type return(true); } return(schemaContext.AreInternalsVisibleTo( method.DeclaringType.Assembly, accessingAssembly)); } return(false); }