コード例 #1
0
        public override void VisitObjCInterfaceDecl(ObjCInterfaceDecl decl, VisitKind visitKind)
        {
            if (visitKind != VisitKind.Enter)
            {
                return;
            }
            if (!decl.IsDefinition)
            {
                return;
            }

            var name = decl.Name;

            // check availability macros to see if the API is available on the OS and not deprecated
            if (!decl.IsAvailable())
            {
                return;
            }

            var framework = Helpers.GetFramework(decl);

            if (framework == null)
            {
                return;
            }

            if (!type_map.TryGetValue(name, out var td))
            {
                Log.On(framework).Add($"!missing-type! {name} not bound");
                // other checks can't be done without an actual type to inspect
                return;
            }

            // check base type
            var nbt = decl.SuperClass?.Name;
            var mbt = td.BaseType?.Resolve().GetName();

            if (nbt != mbt)
            {
                Log.On(framework).Add($"!wrong-base-type! {name} expected {nbt} actual {mbt}");
            }

            // check protocols
            foreach (var protocol in decl.Protocols)
            {
                var pname = protocol.Name;
                if (!ImplementProtocol(pname, td))
                {
                    Log.On(framework).Add($"!missing-protocol-conformance! {name} should conform to {pname}");
                }
            }

            // TODO : check for extraneous protocols

            type_map.Remove(name);
        }
コード例 #2
0
        public override void VisitObjCInterfaceDecl(ObjCInterfaceDecl decl, VisitKind visitKind)
        {
            if (visitKind != VisitKind.Enter)
            {
                return;
            }
            if (!decl.IsDefinition)
            {
                return;
            }

            var name = decl.Name;

            if (name.EndsWith("Internal", StringComparison.Ordinal))
            {
                return;
            }

            // check availability macros to see if the API is available on the OS and not deprecated
            if (!decl.IsAvailable())
            {
                return;
            }

            TypeDefinition td;

            if (!type_map.TryGetValue(name, out td))
            {
                Console.WriteLine("!missing-type! {0} not bound", name);
                // other checks can't be done without an actual type to inspect
                return;
            }

            // check base type
            var nbt = decl.SuperClass?.Name;
            var mbt = td.BaseType?.Resolve().GetName();

            if (nbt != mbt)
            {
                Console.WriteLine("!wrong-base-type! {0} expected {1} actual {2}", name, nbt, mbt);
            }

            // check protocols
            foreach (var protocol in decl.Protocols)
            {
                var pname = protocol.Name;
                if (!ImplementProtocol(pname, td))
                {
                    Console.WriteLine("!missing-protocol-conformance! {0} should conform to {1}", name, pname);
                }
            }

            // TODO : check for extraneous protocols

            type_map.Remove(name);
        }