Exemplo n.º 1
0
        public override void VisitObjCPropertyDecl(ObjCPropertyDecl decl)
        {
            // don't process methods (or types) that are unavailable for the current platform
            if (!decl.IsAvailable() || !(decl.DeclContext as Decl).IsAvailable())
            {
                return;
            }

            // does not look exposed, but part of the dump
            if (decl.DumpToString().IndexOf("UI_APPEARANCE_SELECTOR", StringComparison.OrdinalIgnoreCase) < 0)
            {
                return;
            }

            var getter = decl.Getter;

            if (getter != null)
            {
                VisitObjCMethodDecl(getter);
            }
            var setter = decl.Setter;

            if (setter != null)
            {
                VisitObjCMethodDecl(setter);
            }
        }
Exemplo n.º 2
0
        public override void VisitObjCPropertyDecl(ObjCPropertyDecl decl)
        {
            // protocol members are checked in ObjCProtocolCheck
            if (decl.DeclContext is ObjCProtocolDecl)
            {
                return;
            }

            // 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;
            }

            var nativeArgumentSemantic = decl.Attributes.ToArgumentSemantic();
            var nativeMethodDefinition = decl.QualifiedName;

            if (qualified_properties.TryGetValue(nativeMethodDefinition, out var managedArgumentSemanticList))
            {
                foreach (var entry in managedArgumentSemanticList)
                {
                    var method = entry.Item1;
                    var managedArgumentSemantic = entry.Item2;

                    if (managedArgumentSemantic != nativeArgumentSemantic)
                    {
                        // FIXME: only Copy mistakes are reported now
                        if (managedArgumentSemantic == Helpers.ArgumentSemantic.Copy || nativeArgumentSemantic == Helpers.ArgumentSemantic.Copy)
                        {
                            // FIXME: rule disactivated for now
                            // Log.On (framework).Add ($"!incorrect-argument-semantic! Native '{nativeMethodDefinition}' is declared as ({nativeArgumentSemantic.ToUsableString ().ToLowerInvariant ()}) but mapped to 'ArgumentSemantic.{managedArgumentSemantic.ToUsableString ()}' in '{method}'");
                        }
                    }
                }
            }
        }