// this test checks that all native filters have a managed peer, i.e. against missing filters public void CheckNativeFilters() { Errors = 0; List <string> filters = new List <string> (); int n = 0; string qname = CIFilterType.AssemblyQualifiedName; // that will give us only the list of filters supported by the executing version of iOS foreach (var filter_name in CIFilter.FilterNamesInCategories(null)) { if (Skip(filter_name)) { continue; } string type_name = qname.Replace("CIFilter", filter_name); if (Type.GetType(type_name, false, true) == null) { filters.Add(filter_name); if (BindingOutput != null) { GenerateBinding(CIFilter.FromName(filter_name), BindingOutput); } } n++; } Assert.That(filters.Count, Is.EqualTo(0), "{0} native filters missing: {1}", filters.Count, String.Join(", ", filters)); }
// this test checks that all managed filters have a native peer, i.e. against extra filters public void CheckManagedFilters() { List <string> filters = new List <string> (CIFilter.FilterNamesInCategories(null)); var nspace = CIFilterType.Namespace; var types = CIFilterType.Assembly.GetTypes(); foreach (Type t in types) { if (t.Namespace != nspace) { continue; } if (t.IsAbstract || !CIFilterType.IsAssignableFrom(t)) { continue; } // we need to skip the filters that are not supported by the executing version of iOS if (Skip(t)) { continue; } var ctor = t.GetConstructor(Type.EmptyTypes); if ((ctor == null) || ctor.IsAbstract) { continue; } NSObject obj = ctor.Invoke(null) as NSObject; Assert.That(obj.Handle, Is.Not.EqualTo(IntPtr.Zero), t.Name + ".Handle"); #if false // check base type - we might have our own base type or different names, so it's debug only (not failure) var super = new Class(obj.Class.SuperClass).Name; var bt = t.BaseType.Name; if ((super != bt) && (bt == "CIFilter")) // check if we should (like Apple) use a non-default base type for filters { Console.WriteLine("[WARN] {0}.SuperClass == {1} (native) and {2} managed", t.Name, super, bt); } #endif int result = filters.RemoveAll(s => StringComparer.OrdinalIgnoreCase.Compare(t.Name, s) == 0); Assert.That(result, Is.GreaterThan(0), t.Name); } // in case it's a buggy filter we need to try to remove it from the list too for (int i = filters.Count - 1; i >= 0; i--) { if (Skip(filters [i])) { filters.RemoveAt(i); } } Assert.That(filters.Count, Is.EqualTo(0), "Managed filters not found for {0}", String.Join(", ", filters)); }