ApplyAttributes() public méthode

public ApplyAttributes ( IMemberContext mc, MethodBase builder ) : void
mc IMemberContext
builder System.Reflection.MethodBase
Résultat void
Exemple #1
0
		public override void Emit ()
		{
			base.Emit ();

			if (ReturnType.Type != null) {
				if (ReturnType.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
					Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
				} else if (ReturnType.Type.HasDynamicElement) {
					return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
					Module.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder, ReturnType.Type, Location);
				}

				ConstraintChecker.Check (this, ReturnType.Type, ReturnType.Location);
			}

			Constructor.ParameterInfo.ApplyAttributes (this, Constructor.ConstructorBuilder);
			Constructor.ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);

			parameters.CheckConstraints (this);
			parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder);
			InvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);

			if (BeginInvokeBuilder != null) {
				BeginInvokeBuilder.ParameterInfo.ApplyAttributes (this, BeginInvokeBuilder.MethodBuilder);
				EndInvokeBuilder.ParameterInfo.ApplyAttributes (this, EndInvokeBuilder.MethodBuilder);

				BeginInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
				EndInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
			}
		}
Exemple #2
0
        public override void Emit()
        {
            base.Emit();

            if (declarative_security != null)
            {
                foreach (var de in declarative_security)
                {
#if STATIC
                    TypeBuilder.__AddDeclarativeSecurity(de);
#else
                    TypeBuilder.AddDeclarativeSecurity(de.Key, de.Value);
#endif
                }
            }

            var rtype = ReturnType.Type;
            if (rtype != null)
            {
                if (rtype.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
                {
                    Module.PredefinedAttributes.Dynamic.EmitAttribute(CreateReturnBuilder().Builder);
                }
                else if (rtype.HasDynamicElement)
                {
                    Module.PredefinedAttributes.Dynamic.EmitAttribute(CreateReturnBuilder().Builder, rtype, Location);
                }
                else if (rtype is ReadOnlyReferenceContainer)
                {
                    Module.PredefinedAttributes.IsReadOnly.EmitAttribute(CreateReturnBuilder().Builder);
                }

                if (rtype.HasNamedTupleElement)
                {
                    Module.PredefinedAttributes.TupleElementNames.EmitAttribute(CreateReturnBuilder().Builder, rtype, Location);
                }

                ConstraintChecker.Check(this, ReturnType.Type, ReturnType.Location);
            }

            Constructor.ParameterInfo.ApplyAttributes(this, Constructor.ConstructorBuilder);
            Constructor.ConstructorBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);

            parameters.CheckConstraints(this);
            parameters.ApplyAttributes(this, InvokeBuilder.MethodBuilder);
            InvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);

            if (BeginInvokeBuilder != null)
            {
                BeginInvokeBuilder.ParameterInfo.ApplyAttributes(this, BeginInvokeBuilder.MethodBuilder);
                EndInvokeBuilder.ParameterInfo.ApplyAttributes(this, EndInvokeBuilder.MethodBuilder);

                BeginInvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);
                EndInvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);
            }
        }
Exemple #3
0
        public override void Emit()
        {
            base.Emit();

            if (declarative_security != null)
            {
                foreach (var de in declarative_security)
                {
#if STATIC
                    TypeBuilder.__AddDeclarativeSecurity(de);
#else
                    TypeBuilder.AddDeclarativeSecurity(de.Key, de.Value);
#endif
                }
            }

            if (ReturnType.Type != null)
            {
                if (ReturnType.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
                {
                    return_attributes = new ReturnParameter(this, InvokeBuilder.MethodBuilder, Location);
                    Module.PredefinedAttributes.Dynamic.EmitAttribute(return_attributes.Builder);
                }
                else if (ReturnType.Type.HasDynamicElement)
                {
                    return_attributes = new ReturnParameter(this, InvokeBuilder.MethodBuilder, Location);
                    Module.PredefinedAttributes.Dynamic.EmitAttribute(return_attributes.Builder, ReturnType.Type, Location);
                }

                ConstraintChecker.Check(this, ReturnType.Type, ReturnType.Location);
            }

            Constructor.ParameterInfo.ApplyAttributes(this, Constructor.ConstructorBuilder);
            Constructor.ConstructorBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);

            parameters.CheckConstraints(this);
            parameters.ApplyAttributes(this, InvokeBuilder.MethodBuilder);
            InvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);

            if (BeginInvokeBuilder != null)
            {
                BeginInvokeBuilder.ParameterInfo.ApplyAttributes(this, BeginInvokeBuilder.MethodBuilder);
                EndInvokeBuilder.ParameterInfo.ApplyAttributes(this, EndInvokeBuilder.MethodBuilder);

                BeginInvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);
                EndInvokeBuilder.MethodBuilder.SetImplementationFlags(MethodImplAttributes.Runtime);
            }
        }
Exemple #4
0
        public override void Emit()
        {
            if (TypeManager.IsDynamicType(ret_type))
            {
                return_attributes = new ReturnParameter(InvokeBuilder, Location);
                return_attributes.EmitPredefined(PredefinedAttributes.Get.Dynamic, Location);
            }

            Parameters.ApplyAttributes(InvokeBuilder);

            if (BeginInvokeBuilder != null)
            {
                ParametersCompiled p = (ParametersCompiled)TypeManager.GetParameterData(BeginInvokeBuilder);
                p.ApplyAttributes(BeginInvokeBuilder);
            }

            if (OptAttributes != null)
            {
                OptAttributes.Emit();
            }

            base.Emit();
        }