2 // attribute.cs: Attribute Handler
\r
4 // Author: Ravi Pratap (ravi@ximian.com)
\r
6 // Licensed under the terms of the GNU GPL
\r
8 // (C) 2001 Ximian, Inc (http://www.ximian.com)
\r
13 using System.Diagnostics;
\r
14 using System.Collections;
\r
15 using System.Reflection;
\r
16 using System.Reflection.Emit;
\r
17 using System.Runtime.InteropServices;
\r
18 using System.Runtime.CompilerServices;
\r
21 namespace Mono.CSharp {
\r
23 public class Attribute {
\r
24 public readonly string Name;
\r
25 public readonly ArrayList Arguments;
\r
32 // The following are only meaningful when the attribute
\r
33 // being emitted is one of the builtin ones
\r
35 AttributeTargets Targets;
\r
39 bool UsageAttr = false;
\r
41 MethodImplOptions ImplOptions;
\r
42 UnmanagedType UnmanagedType;
\r
43 CustomAttributeBuilder cb;
\r
45 public Attribute (string name, ArrayList args, Location loc)
\r
52 void Error_InvalidNamedArgument (string name)
\r
54 Report.Error (617, Location, "'" + name + "' is not a valid named attribute " +
\r
55 "argument. Named attribute arguments must be fields which are not " +
\r
56 "readonly, static or const, or properties with a set accessor which "+
\r
60 void Error_AttributeArgumentNotValid ()
\r
62 Report.Error (182, Location,
\r
63 "An attribute argument must be a constant expression, typeof " +
\r
64 "expression or array creation expression");
\r
67 static void Error_AttributeConstructorMismatch (Location loc)
\r
71 "Could not find a constructor for this argument list.");
\r
74 private Type CheckAttributeType (EmitContext ec) {
\r
76 bool isattributeclass = true;
\r
78 t = RootContext.LookupType (ec.DeclSpace, Name, true, Location);
\r
80 isattributeclass = t.IsSubclassOf (TypeManager.attribute_type);
\r
81 if (isattributeclass)
\r
84 t = RootContext.LookupType (ec.DeclSpace, Name + "Attribute", true, Location);
\r
86 if (t.IsSubclassOf (TypeManager.attribute_type))
\r
89 if (!isattributeclass) {
\r
90 Report.Error (616, Location, "'" + Name + "': is not an attribute class");
\r
94 Report.Error (616, Location, "'" + Name + "Attribute': is not an attribute class");
\r
98 246, Location, "Could not find attribute '" + Name + "' (are you" +
\r
99 " missing a using directive or an assembly reference ?)");
\r
103 public Type ResolveType (EmitContext ec)
\r
105 Type = CheckAttributeType (ec);
\r
110 public CustomAttributeBuilder Resolve (EmitContext ec)
\r
113 Type = CheckAttributeType (ec);
\r
117 bool MethodImplAttr = false;
\r
118 bool MarshalAsAttr = false;
\r
122 if (Type == TypeManager.attribute_usage_type)
\r
124 if (Type == TypeManager.methodimpl_attr_type)
\r
125 MethodImplAttr = true;
\r
126 if (Type == TypeManager.marshal_as_attr_type)
\r
127 MarshalAsAttr = true;
\r
129 // Now we extract the positional and named arguments
\r
131 ArrayList pos_args = new ArrayList ();
\r
132 ArrayList named_args = new ArrayList ();
\r
133 int pos_arg_count = 0;
\r
135 if (Arguments != null) {
\r
136 pos_args = (ArrayList) Arguments [0];
\r
137 if (pos_args != null)
\r
138 pos_arg_count = pos_args.Count;
\r
139 if (Arguments.Count > 1)
\r
140 named_args = (ArrayList) Arguments [1];
\r
143 object [] pos_values = new object [pos_arg_count];
\r
146 // First process positional arguments
\r
150 for (i = 0; i < pos_arg_count; i++) {
\r
151 Argument a = (Argument) pos_args [i];
\r
154 if (!a.Resolve (ec, Location))
\r
159 if (e is Constant) {
\r
160 pos_values [i] = ((Constant) e).GetValue ();
\r
161 } else if (e is TypeOf) {
\r
162 pos_values [i] = ((TypeOf) e).TypeArg;
\r
164 Error_AttributeArgumentNotValid ();
\r
169 this.Targets = (AttributeTargets) pos_values [0];
\r
171 if (MethodImplAttr)
\r
172 this.ImplOptions = (MethodImplOptions) pos_values [0];
\r
175 this.UnmanagedType =
\r
176 (System.Runtime.InteropServices.UnmanagedType) pos_values [0];
\r
180 // Now process named arguments
\r
183 ArrayList field_infos = new ArrayList ();
\r
184 ArrayList prop_infos = new ArrayList ();
\r
185 ArrayList field_values = new ArrayList ();
\r
186 ArrayList prop_values = new ArrayList ();
\r
188 for (i = 0; i < named_args.Count; i++) {
\r
189 DictionaryEntry de = (DictionaryEntry) named_args [i];
\r
190 string member_name = (string) de.Key;
\r
191 Argument a = (Argument) de.Value;
\r
194 if (!a.Resolve (ec, Location))
\r
197 Expression member = Expression.MemberLookup (
\r
198 ec, Type, member_name,
\r
199 MemberTypes.Field | MemberTypes.Property,
\r
200 BindingFlags.Public | BindingFlags.Instance,
\r
203 if (member == null || !(member is PropertyExpr || member is FieldExpr)) {
\r
204 Error_InvalidNamedArgument (member_name);
\r
209 if (member is PropertyExpr) {
\r
210 PropertyExpr pe = (PropertyExpr) member;
\r
211 PropertyInfo pi = pe.PropertyInfo;
\r
213 if (!pi.CanWrite) {
\r
214 Error_InvalidNamedArgument (member_name);
\r
218 if (e is Constant) {
\r
219 object o = ((Constant) e).GetValue ();
\r
220 prop_values.Add (o);
\r
223 if (member_name == "AllowMultiple")
\r
224 this.AllowMultiple = (bool) o;
\r
225 if (member_name == "Inherited")
\r
226 this.Inherited = (bool) o;
\r
229 } else if (e is TypeOf) {
\r
230 prop_values.Add (((TypeOf) e).TypeArg);
\r
232 Error_AttributeArgumentNotValid ();
\r
236 prop_infos.Add (pi);
\r
238 } else if (member is FieldExpr) {
\r
239 FieldExpr fe = (FieldExpr) member;
\r
240 FieldInfo fi = fe.FieldInfo;
\r
242 if (fi.IsInitOnly) {
\r
243 Error_InvalidNamedArgument (member_name);
\r
248 // Handle charset here, and set the TypeAttributes
\r
250 if (e is Constant){
\r
251 object value = ((Constant) e).GetValue ();
\r
253 field_values.Add (value);
\r
254 } else if (e is TypeOf) {
\r
255 field_values.Add (((TypeOf) e).TypeArg);
\r
257 Error_AttributeArgumentNotValid ();
\r
261 field_infos.Add (fi);
\r
265 Expression mg = Expression.MemberLookup (
\r
266 ec, Type, ".ctor", MemberTypes.Constructor,
\r
267 BindingFlags.Public | BindingFlags.Instance, Location);
\r
270 Error_AttributeConstructorMismatch (Location);
\r
274 MethodBase constructor = Invocation.OverloadResolve (
\r
275 ec, (MethodGroupExpr) mg, pos_args, Location);
\r
277 if (constructor == null) {
\r
278 Error_AttributeConstructorMismatch (Location);
\r
283 // Now we perform some checks on the positional args as they
\r
284 // cannot be null for a constructor which expects a parameter
\r
288 ParameterData pd = Invocation.GetParameterData (constructor);
\r
290 for (int j = 0; j < pos_arg_count; ++j) {
\r
291 Argument a = (Argument) pos_args [j];
\r
293 if (a.Expr is NullLiteral && pd.ParameterType (j) == TypeManager.object_type) {
\r
294 Error_AttributeArgumentNotValid ();
\r
299 PropertyInfo [] prop_info_arr = new PropertyInfo [prop_infos.Count];
\r
300 FieldInfo [] field_info_arr = new FieldInfo [field_infos.Count];
\r
301 object [] field_values_arr = new object [field_values.Count];
\r
302 object [] prop_values_arr = new object [prop_values.Count];
\r
304 field_infos.CopyTo (field_info_arr, 0);
\r
305 field_values.CopyTo (field_values_arr, 0);
\r
307 prop_values.CopyTo (prop_values_arr, 0);
\r
308 prop_infos.CopyTo (prop_info_arr, 0);
\r
311 cb = new CustomAttributeBuilder (
\r
312 (ConstructorInfo) constructor, pos_values,
\r
313 prop_info_arr, prop_values_arr,
\r
314 field_info_arr, field_values_arr);
\r
316 } catch (NullReferenceException) {
\r
318 // Don't know what to do here
\r
321 -100, Location, "NullReferenceException while trying to create attribute. Something's wrong!");
\r
325 // using System.ComponentModel;
\r
326 // [DefaultValue (CollectionChangeAction.Add)]
\r
327 // class X { static void Main () {} }
\r
331 "The compiler can not encode this attribute in .NET due to\n" +
\r
332 "\ta bug in the .NET runtime. Try the Mono runtime");
\r
338 static string GetValidPlaces (Attribute attr)
\r
340 StringBuilder sb = new StringBuilder ();
\r
341 AttributeTargets targets = 0;
\r
343 TypeContainer a = TypeManager.LookupAttr (attr.Type);
\r
347 System.Attribute [] attrs = null;
\r
350 attrs = System.Attribute.GetCustomAttributes (attr.Type);
\r
353 Report.Error (-20, attr.Location, "Cannot find attribute type " + attr.Name +
\r
354 " (maybe you forgot to set the usage using the" +
\r
355 " AttributeUsage attribute ?).");
\r
359 foreach (System.Attribute tmp in attrs)
\r
360 if (tmp is AttributeUsageAttribute) {
\r
361 targets = ((AttributeUsageAttribute) tmp).ValidOn;
\r
365 targets = a.Targets;
\r
368 if ((targets & AttributeTargets.Assembly) != 0)
\r
369 sb.Append ("'assembly' ");
\r
371 if ((targets & AttributeTargets.Class) != 0)
\r
372 sb.Append ("'class' ");
\r
374 if ((targets & AttributeTargets.Constructor) != 0)
\r
375 sb.Append ("'constructor' ");
\r
377 if ((targets & AttributeTargets.Delegate) != 0)
\r
378 sb.Append ("'delegate' ");
\r
380 if ((targets & AttributeTargets.Enum) != 0)
\r
381 sb.Append ("'enum' ");
\r
383 if ((targets & AttributeTargets.Event) != 0)
\r
384 sb.Append ("'event' ");
\r
386 if ((targets & AttributeTargets.Field) != 0)
\r
387 sb.Append ("'field' ");
\r
389 if ((targets & AttributeTargets.Interface) != 0)
\r
390 sb.Append ("'interface' ");
\r
392 if ((targets & AttributeTargets.Method) != 0)
\r
393 sb.Append ("'method' ");
\r
395 if ((targets & AttributeTargets.Module) != 0)
\r
396 sb.Append ("'module' ");
\r
398 if ((targets & AttributeTargets.Parameter) != 0)
\r
399 sb.Append ("'parameter' ");
\r
401 if ((targets & AttributeTargets.Property) != 0)
\r
402 sb.Append ("'property' ");
\r
404 if ((targets & AttributeTargets.ReturnValue) != 0)
\r
405 sb.Append ("'return value' ");
\r
407 if ((targets & AttributeTargets.Struct) != 0)
\r
408 sb.Append ("'struct' ");
\r
410 return sb.ToString ();
\r
414 public static void Error_AttributeNotValidForElement (Attribute a, Location loc)
\r
417 592, loc, "Attribute '" + a.Name +
\r
418 "' is not valid on this declaration type. " +
\r
419 "It is valid on " + GetValidPlaces (a) + "declarations only.");
\r
422 public static bool CheckAttribute (Attribute a, object element)
\r
424 TypeContainer attr = TypeManager.LookupAttr (a.Type);
\r
425 AttributeTargets targets = 0;
\r
428 if (attr == null) {
\r
430 System.Attribute [] attrs = null;
\r
433 attrs = System.Attribute.GetCustomAttributes (a.Type);
\r
436 Report.Error (-20, a.Location, "Cannot find attribute type " + a.Name +
\r
437 " (maybe you forgot to set the usage using the" +
\r
438 " AttributeUsage attribute ?).");
\r
442 foreach (System.Attribute tmp in attrs)
\r
443 if (tmp is AttributeUsageAttribute)
\r
444 targets = ((AttributeUsageAttribute) tmp).ValidOn;
\r
446 targets = attr.Targets;
\r
448 if (element is Class) {
\r
449 if ((targets & AttributeTargets.Class) != 0)
\r
454 } else if (element is Struct) {
\r
455 if ((targets & AttributeTargets.Struct) != 0)
\r
459 } else if (element is Constructor) {
\r
460 if ((targets & AttributeTargets.Constructor) != 0)
\r
464 } else if (element is Delegate) {
\r
465 if ((targets & AttributeTargets.Delegate) != 0)
\r
469 } else if (element is Enum) {
\r
470 if ((targets & AttributeTargets.Enum) != 0)
\r
474 } else if (element is Event || element is InterfaceEvent) {
\r
475 if ((targets & AttributeTargets.Event) != 0)
\r
479 } else if (element is Field || element is FieldBuilder) {
\r
480 if ((targets & AttributeTargets.Field) != 0)
\r
484 } else if (element is Interface) {
\r
485 if ((targets & AttributeTargets.Interface) != 0)
\r
489 } else if (element is Method || element is Operator || element is InterfaceMethod || element is Accessor) {
\r
490 if ((targets & AttributeTargets.Method) != 0)
\r
494 } else if (element is ParameterBuilder) {
\r
495 if ((targets & AttributeTargets.Parameter) != 0)
\r
499 } else if (element is Property || element is Indexer ||
\r
500 element is InterfaceProperty || element is InterfaceIndexer) {
\r
501 if ((targets & AttributeTargets.Property) != 0)
\r
505 } else if (element is AssemblyBuilder){
\r
506 if ((targets & AttributeTargets.Assembly) != 0)
\r
516 // This method should be invoked to pull the IndexerName attribute from an
\r
517 // Indexer if it exists.
\r
519 public static string ScanForIndexerName (EmitContext ec, Attributes opt_attrs)
\r
521 if (opt_attrs == null)
\r
523 if (opt_attrs.AttributeSections == null)
\r
526 foreach (AttributeSection asec in opt_attrs.AttributeSections) {
\r
527 if (asec.Attributes == null)
\r
530 foreach (Attribute a in asec.Attributes){
\r
531 if (a.ResolveType (ec) == null)
\r
534 if (a.Type != TypeManager.indexer_name_type)
\r
538 // So we have found an IndexerName, pull the data out.
\r
540 if (a.Arguments == null || a.Arguments [0] == null){
\r
541 Error_AttributeConstructorMismatch (a.Location);
\r
544 ArrayList pos_args = (ArrayList) a.Arguments [0];
\r
545 if (pos_args.Count == 0){
\r
546 Error_AttributeConstructorMismatch (a.Location);
\r
550 Argument arg = (Argument) pos_args [0];
\r
551 if (!arg.Resolve (ec, a.Location))
\r
554 Expression e = arg.Expr;
\r
555 if (!(e is StringConstant)){
\r
556 Error_AttributeConstructorMismatch (a.Location);
\r
561 // Remove the attribute from the list
\r
563 asec.Attributes.Remove (a);
\r
565 return (((StringConstant) e).Value);
\r
572 // This pulls the condition name out of a Conditional attribute
\r
574 public string Conditional_GetConditionName ()
\r
577 // So we have a Conditional, pull the data out.
\r
579 if (Arguments == null || Arguments [0] == null){
\r
580 Error_AttributeConstructorMismatch (Location);
\r
584 ArrayList pos_args = (ArrayList) Arguments [0];
\r
585 if (pos_args.Count != 1){
\r
586 Error_AttributeConstructorMismatch (Location);
\r
590 Argument arg = (Argument) pos_args [0];
\r
591 if (!(arg.Expr is StringConstant)){
\r
592 Error_AttributeConstructorMismatch (Location);
\r
596 return ((StringConstant) arg.Expr).Value;
\r
600 // This pulls the obsolete message and error flag out of an Obsolete attribute
\r
602 public string Obsolete_GetObsoleteMessage (out bool is_error)
\r
606 // So we have an Obsolete, pull the data out.
\r
608 if (Arguments == null || Arguments [0] == null)
\r
611 ArrayList pos_args = (ArrayList) Arguments [0];
\r
612 if (pos_args.Count == 0)
\r
614 else if (pos_args.Count > 2){
\r
615 Error_AttributeConstructorMismatch (Location);
\r
619 Argument arg = (Argument) pos_args [0];
\r
620 if (!(arg.Expr is StringConstant)){
\r
621 Error_AttributeConstructorMismatch (Location);
\r
625 if (pos_args.Count == 2){
\r
626 Argument arg2 = (Argument) pos_args [1];
\r
627 if (!(arg2.Expr is BoolConstant)){
\r
628 Error_AttributeConstructorMismatch (Location);
\r
631 is_error = ((BoolConstant) arg2.Expr).Value;
\r
634 return ((StringConstant) arg.Expr).Value;
\r
638 // Applies the attributes to the `builder'.
\r
640 public static void ApplyAttributes (EmitContext ec, object builder, object kind,
\r
641 Attributes opt_attrs, Location loc)
\r
643 if (opt_attrs == null)
\r
645 if (opt_attrs.AttributeSections == null)
\r
648 foreach (AttributeSection asec in opt_attrs.AttributeSections) {
\r
649 if (asec.Attributes == null)
\r
652 if (asec.Target == "assembly" && !(builder is AssemblyBuilder))
\r
655 foreach (Attribute a in asec.Attributes) {
\r
656 CustomAttributeBuilder cb = a.Resolve (ec);
\r
661 if (!(kind is TypeContainer))
\r
662 if (!CheckAttribute (a, kind)) {
\r
663 Error_AttributeNotValidForElement (a, loc);
\r
667 if (kind is Method || kind is Operator || kind is InterfaceMethod ||
\r
668 kind is Accessor) {
\r
669 if (a.Type == TypeManager.methodimpl_attr_type) {
\r
670 if (a.ImplOptions == MethodImplOptions.InternalCall)
\r
671 ((MethodBuilder) builder).
\r
672 SetImplementationFlags (
\r
673 MethodImplAttributes.InternalCall |
\r
674 MethodImplAttributes.Runtime);
\r
675 } else if (a.Type != TypeManager.dllimport_type){
\r
676 ((MethodBuilder) builder).SetCustomAttribute (cb);
\r
678 } else if (kind is Constructor) {
\r
679 ((ConstructorBuilder) builder).SetCustomAttribute (cb);
\r
680 } else if (kind is Field) {
\r
681 ((FieldBuilder) builder).SetCustomAttribute (cb);
\r
682 } else if (kind is Property || kind is Indexer ||
\r
683 kind is InterfaceProperty || kind is InterfaceIndexer) {
\r
684 ((PropertyBuilder) builder).SetCustomAttribute (cb);
\r
685 } else if (kind is Event || kind is InterfaceEvent) {
\r
686 ((MyEventBuilder) builder).SetCustomAttribute (cb);
\r
687 } else if (kind is ParameterBuilder) {
\r
689 if (a.Type == TypeManager.marshal_as_attr_type) {
\r
690 UnmanagedMarshal marshal =
\r
691 UnmanagedMarshal.DefineUnmanagedMarshal (a.UnmanagedType);
\r
693 ((ParameterBuilder) builder).SetMarshal (marshal);
\r
695 ((ParameterBuilder) builder).SetCustomAttribute (cb);
\r
697 } else if (kind is Enum) {
\r
698 ((TypeBuilder) builder).SetCustomAttribute (cb);
\r
700 } else if (kind is TypeContainer) {
\r
701 TypeContainer tc = (TypeContainer) kind;
\r
704 tc.Targets = a.Targets;
\r
705 tc.AllowMultiple = a.AllowMultiple;
\r
706 tc.Inherited = a.Inherited;
\r
708 } else if (a.Type == TypeManager.default_member_type) {
\r
709 if (tc.Indexers != null) {
\r
710 Report.Error (646, loc,
\r
711 "Cannot specify the DefaultMember attribute on" +
\r
712 " a type containing an indexer");
\r
717 if (!CheckAttribute (a, kind)) {
\r
718 Error_AttributeNotValidForElement (a, loc);
\r
724 ((TypeBuilder) builder).SetCustomAttribute (cb);
\r
725 } catch (System.ArgumentException) {
\r
728 "The CharSet named property on StructLayout\n"+
\r
729 "\tdoes not work correctly on Microsoft.NET\n"+
\r
730 "\tYou might want to remove the CharSet declaration\n"+
\r
731 "\tor compile using the Mono runtime instead of the\n"+
\r
732 "\tMicrosoft .NET runtime");
\r
735 } else if (kind is Interface) {
\r
736 Interface iface = (Interface) kind;
\r
738 if ((a.Type == TypeManager.default_member_type) &&
\r
739 (iface.InterfaceIndexers != null)) {
\r
742 "Cannot specify the DefaultMember attribute on" +
\r
743 " a type containing an indexer");
\r
747 if (!CheckAttribute (a, kind)) {
\r
748 Error_AttributeNotValidForElement (a, loc);
\r
752 ((TypeBuilder) builder).SetCustomAttribute (cb);
\r
753 } else if (kind is AssemblyBuilder){
\r
754 ((AssemblyBuilder) builder).SetCustomAttribute (cb);
\r
755 } else if (kind is ModuleBuilder) {
\r
756 ((ModuleBuilder) builder).SetCustomAttribute (cb);
\r
757 } else if (kind is FieldBuilder) {
\r
758 ((FieldBuilder) builder).SetCustomAttribute (cb);
\r
760 throw new Exception ("Unknown kind: " + kind);
\r
765 public MethodBuilder DefinePInvokeMethod (EmitContext ec, TypeBuilder builder, string name,
\r
766 MethodAttributes flags, Type ret_type, Type [] param_types)
\r
769 // We extract from the attribute the information we need
\r
772 if (Arguments == null) {
\r
773 Console.WriteLine ("Internal error : this is not supposed to happen !");
\r
777 Type = CheckAttributeType (ec);
\r
781 ArrayList named_args = new ArrayList ();
\r
783 ArrayList pos_args = (ArrayList) Arguments [0];
\r
784 if (Arguments.Count > 1)
\r
785 named_args = (ArrayList) Arguments [1];
\r
788 string dll_name = null;
\r
790 Argument tmp = (Argument) pos_args [0];
\r
792 if (!tmp.Resolve (ec, Location))
\r
795 if (tmp.Expr is Constant)
\r
796 dll_name = (string) ((Constant) tmp.Expr).GetValue ();
\r
798 Error_AttributeArgumentNotValid ();
\r
802 // Now we process the named arguments
\r
803 CallingConvention cc = CallingConvention.Winapi;
\r
804 CharSet charset = CharSet.Ansi;
\r
805 bool preserve_sig = true;
\r
806 bool exact_spelling = false;
\r
807 bool set_last_err = false;
\r
808 string entry_point = null;
\r
810 for (int i = 0; i < named_args.Count; i++) {
\r
812 DictionaryEntry de = (DictionaryEntry) named_args [i];
\r
814 string member_name = (string) de.Key;
\r
815 Argument a = (Argument) de.Value;
\r
817 if (!a.Resolve (ec, Location))
\r
820 Expression member = Expression.MemberLookup (
\r
821 ec, Type, member_name,
\r
822 MemberTypes.Field | MemberTypes.Property,
\r
823 BindingFlags.Public | BindingFlags.Instance,
\r
826 if (member == null || !(member is FieldExpr)) {
\r
827 Error_InvalidNamedArgument (member_name);
\r
831 if (member is FieldExpr) {
\r
832 FieldExpr fe = (FieldExpr) member;
\r
833 FieldInfo fi = fe.FieldInfo;
\r
835 if (fi.IsInitOnly) {
\r
836 Error_InvalidNamedArgument (member_name);
\r
840 if (a.Expr is Constant) {
\r
841 Constant c = (Constant) a.Expr;
\r
843 if (member_name == "CallingConvention")
\r
844 cc = (CallingConvention) c.GetValue ();
\r
845 else if (member_name == "CharSet")
\r
846 charset = (CharSet) c.GetValue ();
\r
847 else if (member_name == "EntryPoint")
\r
848 entry_point = (string) c.GetValue ();
\r
849 else if (member_name == "SetLastError")
\r
850 set_last_err = (bool) c.GetValue ();
\r
851 else if (member_name == "ExactSpelling")
\r
852 exact_spelling = (bool) c.GetValue ();
\r
853 else if (member_name == "PreserveSig")
\r
854 preserve_sig = (bool) c.GetValue ();
\r
856 Error_AttributeArgumentNotValid ();
\r
863 if (entry_point == null)
\r
864 entry_point = name;
\r
866 MethodBuilder mb = builder.DefinePInvokeMethod (
\r
867 name, dll_name, entry_point, flags | MethodAttributes.HideBySig,
\r
868 CallingConventions.Standard,
\r
875 mb.SetImplementationFlags (MethodImplAttributes.PreserveSig);
\r
882 public class AttributeSection {
\r
884 public readonly string Target;
\r
885 public readonly ArrayList Attributes;
\r
887 public AttributeSection (string target, ArrayList attrs)
\r
890 Attributes = attrs;
\r
895 public class Attributes {
\r
896 public ArrayList AttributeSections;
\r
897 public Location Location;
\r
899 public Attributes (AttributeSection a, Location loc)
\r
901 AttributeSections = new ArrayList ();
\r
902 AttributeSections.Add (a);
\r
906 public void AddAttribute (AttributeSection a)
\r
909 AttributeSections.Add (a);
\r