Ejemplo n.º 1
0
        /// <summary>
        /// It is called very early therefore can resolve only predefined attributes
        /// </summary>
        void ResolveGlobalAttributes()
        {
            if (OptAttributes == null)
            {
                return;
            }

            if (!OptAttributes.CheckTargets())
            {
                return;
            }

            // FIXME: Define is wrong as the type may not exist yet
            var DefaultCharSet_attr = new PredefinedAttribute(this, "System.Runtime.InteropServices", "DefaultCharSetAttribute");

            DefaultCharSet_attr.Define();
            Attribute a = ResolveModuleAttribute(DefaultCharSet_attr);

            if (a != null)
            {
                has_default_charset = true;
                DefaultCharSet      = a.GetCharSetValue();
                switch (DefaultCharSet)
                {
                case CharSet.Ansi:
                case CharSet.None:
                    break;

                case CharSet.Auto:
                    DefaultCharSetType = TypeAttributes.AutoClass;
                    break;

                case CharSet.Unicode:
                    DefaultCharSetType = TypeAttributes.UnicodeClass;
                    break;

                default:
                    Report.Error(1724, a.Location, "Value specified for the argument to `{0}' is not valid",
                                 DefaultCharSet_attr.GetSignatureForError());
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// It is called very early therefore can resolve only predefined attributes
        /// </summary>
        public void Resolve()
        {
            if (OptAttributes == null)
            {
                return;
            }

            if (!OptAttributes.CheckTargets())
            {
                return;
            }

            Attribute a = ResolveAttribute(PredefinedAttributes.Get.DefaultCharset);

            if (a != null)
            {
                has_default_charset = true;
                DefaultCharSet      = a.GetCharSetValue();
                switch (DefaultCharSet)
                {
                case CharSet.Ansi:
                case CharSet.None:
                    break;

                case CharSet.Auto:
                    DefaultCharSetType = TypeAttributes.AutoClass;
                    break;

                case CharSet.Unicode:
                    DefaultCharSetType = TypeAttributes.UnicodeClass;
                    break;

                default:
                    Report.Error(1724, a.Location, "Value specified for the argument to 'System.Runtime.InteropServices.DefaultCharSetAttribute' is not valid");
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public void Resolve()
        {
            if (RootContext.Unsafe)
            {
                //
                // Emits [assembly: SecurityPermissionAttribute (SecurityAction.RequestMinimum, SkipVerification = true)]
                // when -unsafe option was specified
                //

                Location loc = Location.Null;

                MemberAccess system_security_permissions = new MemberAccess(new MemberAccess(
                                                                                new QualifiedAliasMember(QualifiedAliasMember.GlobalAlias, "System", loc), "Security", loc), "Permissions", loc);

                Arguments pos = new Arguments(1);
                pos.Add(new Argument(new MemberAccess(new MemberAccess(system_security_permissions, "SecurityAction", loc), "RequestMinimum")));

                Arguments named = new Arguments(1);
                named.Add(new NamedArgument(new LocatedToken(loc, "SkipVerification"), (new BoolLiteral(true, loc))));

                GlobalAttribute g = new GlobalAttribute(new NamespaceEntry(null, null, null), "assembly",
                                                        new MemberAccess(system_security_permissions, "SecurityPermissionAttribute"),
                                                        new Arguments[] { pos, named }, loc, false);
                g.AttachTo(this, this);

                if (g.Resolve() != null)
                {
                    declarative_security = new ListDictionary();
                    g.ExtractSecurityPermissionSet(declarative_security);
                }
            }

            if (OptAttributes == null)
            {
                return;
            }

            // Ensure that we only have GlobalAttributes, since the Search isn't safe with other types.
            if (!OptAttributes.CheckTargets())
            {
                return;
            }

            ClsCompliantAttribute = ResolveAttribute(PredefinedAttributes.Get.CLSCompliant);

            if (ClsCompliantAttribute != null)
            {
                is_cls_compliant = ClsCompliantAttribute.GetClsCompliantAttributeValue();
            }

            Attribute a = ResolveAttribute(PredefinedAttributes.Get.RuntimeCompatibility);

            if (a != null)
            {
                object val = a.GetPropertyValue("WrapNonExceptionThrows");
                if (val != null)
                {
                    wrap_non_exception_throws = (bool)val;
                }
            }
        }