Exemple #1
0
        protected virtual bool OnValidate(CodeGenerationOptions opt, GenericParameterDefinitionList type_params)
        {
            if (Name.Length > TypeNamePrefix.Length &&
                (Name [TypeNamePrefix.Length] == '.' || Char.IsDigit(Name [TypeNamePrefix.Length])))              // see bug #5111
            {
                return(false);
            }

            if (!support.ValidateNamespace())
            {
                return(false);
            }

            List <GenBase> valid_nests = new List <GenBase> ();

            foreach (GenBase gen in nested_types)
            {
                if (gen.Validate(opt, TypeParameters))
                {
                    valid_nests.Add(gen);
                }
            }
            nested_types = valid_nests;

            AdjustNestedTypeFullName(this);

            foreach (string iface_name in iface_names)
            {
                ISymbol isym = SymbolTable.Lookup(iface_name);
                if (isym != null && isym.Validate(opt, TypeParameters))
                {
                    ifaces.Add(isym);
                }
                else
                {
                    if (isym == null)
                    {
                        Report.Warning(0, Report.WarningGenBase + 0, "For type {0}, base interface {1} does not exist.", FullName, iface_name);
                    }
                    else
                    {
                        Report.Warning(0, Report.WarningGenBase + 0, "For type {0}, base interface {1} is invalid.", FullName, iface_name);
                    }
                    iface_validation_failed = true;
                }
            }

            List <Field> valid_fields = new List <Field> ();

            foreach (Field f in fields)
            {
                if (!f.Validate(opt, TypeParameters))
                {
                    continue;
                }
                valid_fields.Add(f);
            }
            fields = valid_fields;

            int method_cnt = methods.Count;

            methods = methods.Where(m => ValidateMethod(opt, m)).ToList();
            method_validation_failed = method_cnt != methods.Count;
            foreach (Method m in methods)
            {
                if (m.IsVirtual)
                {
                    has_virtual_methods = true;
                }
                if (m.Name == "HashCode" && m.Parameters.Count == 0)
                {
                    m.IsOverride = true;
                    m.Name       = "GetHashCode";
                }
                jni_sig_hash [m.JavaName + m.JniSignature] = m;
                if ((m.Name == "ToString" && m.Parameters.Count == 0) || (BaseSymbol != null && BaseSymbol.ContainsMethod(m, true)))
                {
                    m.IsOverride = true;
                }
            }
            return(true);
        }