Mono.CSharp.ModuleContainer.ResolveAssemblyAttribute C# (CSharp) Method

ResolveAssemblyAttribute() public method

public ResolveAssemblyAttribute ( PredefinedAttribute a_type ) : Attribute
a_type PredefinedAttribute
return Attribute
		public Attribute ResolveAssemblyAttribute (PredefinedAttribute a_type)
		{
			Attribute a = OptAttributes.Search ("assembly", a_type);
			if (a != null) {
				a.Resolve ();
			}
			return a;
		}

Usage Example

示例#1
0
文件: assembly.cs 项目: jj-jabb/mono
        public void Resolve()
        {
            if (Compiler.Settings.Unsafe && module.PredefinedTypes.SecurityAction.Define())
            {
                //
                // 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);

                var req_min = module.PredefinedMembers.SecurityActionRequestMinimum.Resolve(loc);

                Arguments pos = new Arguments(1);
                pos.Add(new Argument(req_min.GetConstant(null)));

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

                Attribute g = new Attribute("assembly",
                                            new MemberAccess(system_security_permissions, "SecurityPermissionAttribute"),
                                            new Arguments[] { pos, named }, loc, false);
                g.AttachTo(module, module);

                // Disable no-location warnings (e.g. obsolete) for compiler generated attribute
                Compiler.Report.DisableReporting();
                try {
                    var ctor = g.Resolve();
                    if (ctor != null)
                    {
                        g.ExtractSecurityPermissionSet(ctor, ref declarative_security);
                    }
                } finally {
                    Compiler.Report.EnableReporting();
                }
            }

            if (module.OptAttributes == null)
            {
                return;
            }

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

            cls_attribute = module.ResolveAssemblyAttribute(module.PredefinedAttributes.CLSCompliant);

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

            if (added_modules != null && Compiler.Settings.VerifyClsCompliance && is_cls_compliant)
            {
                foreach (var m in added_modules)
                {
                    if (!m.IsCLSCompliant)
                    {
                        Report.Error(3013,
                                     "Added modules must be marked with the CLSCompliant attribute to match the assembly",
                                     m.Name);
                    }
                }
            }

            Attribute a = module.ResolveAssemblyAttribute(module.PredefinedAttributes.RuntimeCompatibility);

            if (a != null)
            {
                var val = a.GetNamedValue("WrapNonExceptionThrows") as BoolConstant;
                if (val != null)
                {
                    wrap_non_exception_throws = val.Value;
                }
            }
        }