コード例 #1
0
        static TypeDefinition GetType(ObjCInterfaceDecl decl)
        {
            TypeDefinition td;

            types.TryGetValue(decl.Name, out td);
            return(td);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: test.cs プロジェクト: zippo227/xamarin-macios
        public override void VisitObjCInterfaceDecl(ObjCInterfaceDecl decl, VisitKind visitKind)
        {
            if (visitKind == VisitKind.Enter && !IsPrivate(decl.Name))
            {
                currentInterfaceDecl = decl;
                currentType          = APITestTool.XamarinMacAssembly.GetTypes().FirstOrDefault(x => x.Name == Extrospection.Helpers.GetManagedName(decl.Name));          // Technically SingleOrDefault, but significantly slower

                // If we couldn't match up a type, we're going to skip testing for now.
                if (currentType == null)
                {
                    currentInterfaceDecl = null;
                }
            }
            else
            {
                currentInterfaceDecl = null;
                currentType          = null;
            }
        }
コード例 #5
0
 public override void VisitObjCInterfaceDecl(ObjCInterfaceDecl decl, VisitKind visitKind) => VisitItem(decl, visitKind);