Merge pull request #228 from QuickJack/3e163743eda89cc8c239779a75dd245be12aee3c
[mono.git] / mcs / class / IKVM.Reflection / Module.cs
1 /*
2   Copyright (C) 2009-2012 Jeroen Frijters
3
4   This software is provided 'as-is', without any express or implied
5   warranty.  In no event will the authors be held liable for any damages
6   arising from the use of this software.
7
8   Permission is granted to anyone to use this software for any purpose,
9   including commercial applications, and to alter it and redistribute it
10   freely, subject to the following restrictions:
11
12   1. The origin of this software must not be misrepresented; you must not
13      claim that you wrote the original software. If you use this software
14      in a product, an acknowledgment in the product documentation would be
15      appreciated but is not required.
16   2. Altered source versions must be plainly marked as such, and must not be
17      misrepresented as being the original software.
18   3. This notice may not be removed or altered from any source distribution.
19
20   Jeroen Frijters
21   jeroen@frijters.net
22   
23 */
24 using System;
25 using System.Collections.Generic;
26 using IKVM.Reflection.Metadata;
27 using IKVM.Reflection.Reader;
28
29 namespace IKVM.Reflection
30 {
31         public sealed class RawModule : IDisposable
32         {
33                 private readonly ModuleReader module;
34                 private readonly bool isManifestModule;
35                 private bool imported;
36
37                 internal RawModule(ModuleReader module)
38                 {
39                         this.module = module;
40                         this.isManifestModule = module.Assembly != null;
41                 }
42
43                 public string Location
44                 {
45                         get { return module.FullyQualifiedName; }
46                 }
47
48                 public bool IsManifestModule
49                 {
50                         get { return isManifestModule; }
51                 }
52
53                 public Guid ModuleVersionId
54                 {
55                         get { return module.ModuleVersionId; }
56                 }
57
58                 private void CheckManifestModule()
59                 {
60                         if (!IsManifestModule)
61                         {
62                                 throw new BadImageFormatException("Module does not contain a manifest");
63                         }
64                 }
65
66                 public AssemblyName GetAssemblyName()
67                 {
68                         CheckManifestModule();
69                         return module.Assembly.GetName();
70                 }
71
72                 public AssemblyName[] GetReferencedAssemblies()
73                 {
74                         return module.__GetReferencedAssemblies();
75                 }
76
77                 public void Dispose()
78                 {
79                         if (!imported)
80                         {
81                                 module.stream.Dispose();
82                         }
83                 }
84
85                 internal AssemblyReader ToAssembly()
86                 {
87                         if (imported)
88                         {
89                                 throw new InvalidOperationException();
90                         }
91                         imported = true;
92                         return (AssemblyReader)module.Assembly;
93                 }
94
95                 internal Module ToModule(Assembly assembly)
96                 {
97                         if (module.Assembly != null)
98                         {
99                                 throw new InvalidOperationException();
100                         }
101                         imported = true;
102                         module.SetAssembly(assembly);
103                         return module;
104                 }
105         }
106
107         public abstract class Module : ICustomAttributeProvider
108         {
109                 internal readonly Universe universe;
110                 internal readonly ModuleTable ModuleTable = new ModuleTable();
111                 internal readonly TypeRefTable TypeRef = new TypeRefTable();
112                 internal readonly TypeDefTable TypeDef = new TypeDefTable();
113                 internal readonly FieldPtrTable FieldPtr = new FieldPtrTable();
114                 internal readonly FieldTable Field = new FieldTable();
115                 internal readonly MemberRefTable MemberRef = new MemberRefTable();
116                 internal readonly ConstantTable Constant = new ConstantTable();
117                 internal readonly CustomAttributeTable CustomAttribute = new CustomAttributeTable();
118                 internal readonly FieldMarshalTable FieldMarshal = new FieldMarshalTable();
119                 internal readonly DeclSecurityTable DeclSecurity = new DeclSecurityTable();
120                 internal readonly ClassLayoutTable ClassLayout = new ClassLayoutTable();
121                 internal readonly FieldLayoutTable FieldLayout = new FieldLayoutTable();
122                 internal readonly ParamPtrTable ParamPtr = new ParamPtrTable();
123                 internal readonly ParamTable Param = new ParamTable();
124                 internal readonly InterfaceImplTable InterfaceImpl = new InterfaceImplTable();
125                 internal readonly StandAloneSigTable StandAloneSig = new StandAloneSigTable();
126                 internal readonly EventMapTable EventMap = new EventMapTable();
127                 internal readonly EventPtrTable EventPtr = new EventPtrTable();
128                 internal readonly EventTable Event = new EventTable();
129                 internal readonly PropertyMapTable PropertyMap = new PropertyMapTable();
130                 internal readonly PropertyPtrTable PropertyPtr = new PropertyPtrTable();
131                 internal readonly PropertyTable Property = new PropertyTable();
132                 internal readonly MethodSemanticsTable MethodSemantics = new MethodSemanticsTable();
133                 internal readonly MethodImplTable MethodImpl = new MethodImplTable();
134                 internal readonly ModuleRefTable ModuleRef = new ModuleRefTable();
135                 internal readonly TypeSpecTable TypeSpec = new TypeSpecTable();
136                 internal readonly ImplMapTable ImplMap = new ImplMapTable();
137                 internal readonly FieldRVATable FieldRVA = new FieldRVATable();
138                 internal readonly AssemblyTable AssemblyTable = new AssemblyTable();
139                 internal readonly AssemblyRefTable AssemblyRef = new AssemblyRefTable();
140                 internal readonly MethodPtrTable MethodPtr = new MethodPtrTable();
141                 internal readonly MethodDefTable MethodDef = new MethodDefTable();
142                 internal readonly NestedClassTable NestedClass = new NestedClassTable();
143                 internal readonly FileTable File = new FileTable();
144                 internal readonly ExportedTypeTable ExportedType = new ExportedTypeTable();
145                 internal readonly ManifestResourceTable ManifestResource = new ManifestResourceTable();
146                 internal readonly GenericParamTable GenericParam = new GenericParamTable();
147                 internal readonly MethodSpecTable MethodSpec = new MethodSpecTable();
148                 internal readonly GenericParamConstraintTable GenericParamConstraint = new GenericParamConstraintTable();
149                 protected ulong sortedTableMask;
150
151                 protected Module(Universe universe)
152                 {
153                         this.universe = universe;
154                 }
155
156                 internal Table[] GetTables()
157                 {
158                         Table[] tables = new Table[64];
159                         tables[ModuleTable.Index] = ModuleTable;
160                         tables[TypeRefTable.Index] = TypeRef;
161                         tables[TypeDefTable.Index] = TypeDef;
162                         tables[FieldPtrTable.Index] = FieldPtr;
163                         tables[FieldTable.Index] = Field;
164                         tables[MemberRefTable.Index] = MemberRef;
165                         tables[ConstantTable.Index] = Constant;
166                         tables[CustomAttributeTable.Index] = CustomAttribute;
167                         tables[FieldMarshalTable.Index] = FieldMarshal;
168                         tables[DeclSecurityTable.Index] = DeclSecurity;
169                         tables[ClassLayoutTable.Index] = ClassLayout;
170                         tables[FieldLayoutTable.Index] = FieldLayout;
171                         tables[ParamPtrTable.Index] = ParamPtr;
172                         tables[ParamTable.Index] = Param;
173                         tables[InterfaceImplTable.Index] = InterfaceImpl;
174                         tables[StandAloneSigTable.Index] = StandAloneSig;
175                         tables[EventMapTable.Index] = EventMap;
176                         tables[EventPtrTable.Index] = EventPtr;
177                         tables[EventTable.Index] = Event;
178                         tables[PropertyMapTable.Index] = PropertyMap;
179                         tables[PropertyPtrTable.Index] = PropertyPtr;
180                         tables[PropertyTable.Index] = Property;
181                         tables[MethodSemanticsTable.Index] = MethodSemantics;
182                         tables[MethodImplTable.Index] = MethodImpl;
183                         tables[ModuleRefTable.Index] = ModuleRef;
184                         tables[TypeSpecTable.Index] = TypeSpec;
185                         tables[ImplMapTable.Index] = ImplMap;
186                         tables[FieldRVATable.Index] = FieldRVA;
187                         tables[AssemblyTable.Index] = AssemblyTable;
188                         tables[AssemblyRefTable.Index] = AssemblyRef;
189                         tables[MethodPtrTable.Index] = MethodPtr;
190                         tables[MethodDefTable.Index] = MethodDef;
191                         tables[NestedClassTable.Index] = NestedClass;
192                         tables[FileTable.Index] = File;
193                         tables[ExportedTypeTable.Index] = ExportedType;
194                         tables[ManifestResourceTable.Index] = ManifestResource;
195                         tables[GenericParamTable.Index] = GenericParam;
196                         tables[MethodSpecTable.Index] = MethodSpec;
197                         tables[GenericParamConstraintTable.Index] = GenericParamConstraint;
198                         return tables;
199                 }
200
201                 public virtual void __GetDataDirectoryEntry(int index, out int rva, out int length)
202                 {
203                         throw new NotSupportedException();
204                 }
205
206                 public virtual long __RelativeVirtualAddressToFileOffset(int rva)
207                 {
208                         throw new NotSupportedException();
209                 }
210
211                 public virtual bool __GetSectionInfo(int rva, out string name, out int characteristics)
212                 {
213                         throw new NotSupportedException();
214                 }
215
216                 public virtual int __ReadDataFromRVA(int rva, byte[] data, int offset, int length)
217                 {
218                         throw new NotSupportedException();
219                 }
220
221                 public virtual void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
222                 {
223                         throw new NotSupportedException();
224                 }
225
226                 public virtual int __Subsystem
227                 {
228                         get { throw new NotSupportedException(); }
229                 }
230
231                 public FieldInfo GetField(string name)
232                 {
233                         return GetField(name, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);
234                 }
235
236                 public FieldInfo GetField(string name, BindingFlags bindingFlags)
237                 {
238                         return IsResource() ? null : GetModuleType().GetField(name, bindingFlags | BindingFlags.DeclaredOnly);
239                 }
240
241                 public FieldInfo[] GetFields()
242                 {
243                         return GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);
244                 }
245
246                 public FieldInfo[] GetFields(BindingFlags bindingFlags)
247                 {
248                         return IsResource() ? Empty<FieldInfo>.Array : GetModuleType().GetFields(bindingFlags | BindingFlags.DeclaredOnly);
249                 }
250
251                 public MethodInfo GetMethod(string name)
252                 {
253                         return IsResource() ? null : GetModuleType().GetMethod(name, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);
254                 }
255
256                 public MethodInfo GetMethod(string name, Type[] types)
257                 {
258                         return IsResource() ? null : GetModuleType().GetMethod(name, BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly, null, types, null);
259                 }
260
261                 public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
262                 {
263                         return IsResource() ? null : GetModuleType().GetMethod(name, bindingAttr | BindingFlags.DeclaredOnly, binder, callConv, types, modifiers);
264                 }
265
266                 public MethodInfo[] GetMethods()
267                 {
268                         return GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);
269                 }
270
271                 public MethodInfo[] GetMethods(BindingFlags bindingFlags)
272                 {
273                         return IsResource() ? Empty<MethodInfo>.Array : GetModuleType().GetMethods(bindingFlags | BindingFlags.DeclaredOnly);
274                 }
275
276                 public ConstructorInfo __ModuleInitializer
277                 {
278                         get { return IsResource() ? null : GetModuleType().TypeInitializer; }
279                 }
280
281                 public virtual byte[] ResolveSignature(int metadataToken)
282                 {
283                         throw new NotSupportedException();
284                 }
285
286                 public virtual __StandAloneMethodSig __ResolveStandAloneMethodSig(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
287                 {
288                         throw new NotSupportedException();
289                 }
290
291                 public int MetadataToken
292                 {
293                         get { return IsResource() ? 0 : 1; }
294                 }
295
296                 public abstract int MDStreamVersion { get ;}
297                 public abstract Assembly Assembly { get; }
298                 public abstract string FullyQualifiedName { get; }
299                 public abstract string Name { get; }
300                 public abstract Guid ModuleVersionId { get; }
301                 public abstract Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments);
302                 public abstract MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments);
303                 public abstract FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments);
304                 public abstract MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments);
305
306                 public abstract string ResolveString(int metadataToken);
307                 public abstract Type[] __ResolveOptionalParameterTypes(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments, out CustomModifiers[] customModifiers);
308                 public abstract string ScopeName { get; }
309
310                 internal abstract void GetTypesImpl(List<Type> list);
311
312                 internal abstract Type FindType(TypeName name);
313
314                 [Obsolete("Please use __ResolveOptionalParameterTypes(int, Type[], Type[], out CustomModifiers[]) instead.")]
315                 public Type[] __ResolveOptionalParameterTypes(int metadataToken)
316                 {
317                         CustomModifiers[] dummy;
318                         return __ResolveOptionalParameterTypes(metadataToken, null, null, out dummy);
319                 }
320
321                 public Type GetType(string className)
322                 {
323                         return GetType(className, false, false);
324                 }
325
326                 public Type GetType(string className, bool ignoreCase)
327                 {
328                         return GetType(className, false, ignoreCase);
329                 }
330
331                 public Type GetType(string className, bool throwOnError, bool ignoreCase)
332                 {
333                         if (ignoreCase)
334                         {
335                                 throw new NotImplementedException();
336                         }
337                         TypeNameParser parser = TypeNameParser.Parse(className, throwOnError);
338                         if (parser.Error)
339                         {
340                                 return null;
341                         }
342                         if (parser.AssemblyName != null)
343                         {
344                                 if (throwOnError)
345                                 {
346                                         throw new ArgumentException("Type names passed to Module.GetType() must not specify an assembly.");
347                                 }
348                                 else
349                                 {
350                                         return null;
351                                 }
352                         }
353                         Type type = FindType(TypeName.Split(TypeNameParser.Unescape(parser.FirstNamePart)));
354                         if (type == null && __IsMissing)
355                         {
356                                 throw new MissingModuleException((MissingModule)this);
357                         }
358                         return parser.Expand(type, this.Assembly, throwOnError, className, false);
359                 }
360
361                 public Type[] GetTypes()
362                 {
363                         List<Type> list = new List<Type>();
364                         GetTypesImpl(list);
365                         return list.ToArray();
366                 }
367
368                 public Type[] FindTypes(TypeFilter filter, object filterCriteria)
369                 {
370                         List<Type> list = new List<Type>();
371                         foreach (Type type in GetTypes())
372                         {
373                                 if (filter(type, filterCriteria))
374                                 {
375                                         list.Add(type);
376                                 }
377                         }
378                         return list.ToArray();
379                 }
380
381                 public virtual bool IsResource()
382                 {
383                         return false;
384                 }
385
386                 public Type ResolveType(int metadataToken)
387                 {
388                         return ResolveType(metadataToken, null, null);
389                 }
390
391                 public MethodBase ResolveMethod(int metadataToken)
392                 {
393                         return ResolveMethod(metadataToken, null, null);
394                 }
395
396                 public FieldInfo ResolveField(int metadataToken)
397                 {
398                         return ResolveField(metadataToken, null, null);
399                 }
400
401                 public MemberInfo ResolveMember(int metadataToken)
402                 {
403                         return ResolveMember(metadataToken, null, null);
404                 }
405
406                 public bool IsDefined(Type attributeType, bool inherit)
407                 {
408                         return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit).Count != 0;
409                 }
410
411                 public IList<CustomAttributeData> __GetCustomAttributes(Type attributeType, bool inherit)
412                 {
413                         return CustomAttributeData.__GetCustomAttributes(this, attributeType, inherit);
414                 }
415
416                 public virtual IList<CustomAttributeData> __GetPlaceholderAssemblyCustomAttributes(bool multiple, bool security)
417                 {
418                         return Empty<CustomAttributeData>.Array;
419                 }
420
421                 public abstract AssemblyName[] __GetReferencedAssemblies();
422
423                 public virtual void __ResolveReferencedAssemblies(Assembly[] assemblies)
424                 {
425                         throw new NotSupportedException();
426                 }
427
428                 public abstract string[] __GetReferencedModules();
429
430                 public abstract Type[] __GetReferencedTypes();
431
432                 public abstract Type[] __GetExportedTypes();
433
434                 public virtual bool __IsMissing
435                 {
436                         get { return false; }
437                 }
438
439                 public long __ImageBase
440                 {
441                         get { return GetImageBaseImpl(); }
442                 }
443
444                 protected abstract long GetImageBaseImpl();
445
446                 public virtual long __StackReserve
447                 {
448                         get { throw new NotSupportedException(); }
449                 }
450
451                 public virtual int __FileAlignment
452                 {
453                         get { throw new NotSupportedException(); }
454                 }
455
456                 public virtual byte[] __ModuleHash
457                 {
458                         get { throw new NotSupportedException(); }
459                 }
460
461                 public virtual int __EntryPointRVA
462                 {
463                         get { throw new NotSupportedException(); }
464                 }
465
466                 public virtual int __EntryPointToken
467                 {
468                         get { throw new NotSupportedException(); }
469                 }
470
471                 public virtual string __ImageRuntimeVersion
472                 {
473                         get { throw new NotSupportedException(); }
474                 }
475
476                 public IEnumerable<CustomAttributeData> __EnumerateCustomAttributeTable()
477                 {
478                         List<CustomAttributeData> list = new List<CustomAttributeData>(CustomAttribute.RowCount);
479                         for (int i = 0; i < CustomAttribute.RowCount; i++)
480                         {
481                                 list.Add(new CustomAttributeData(this, i));
482                         }
483                         return list;
484                 }
485
486                 [Obsolete]
487                 public List<CustomAttributeData> __GetCustomAttributesFor(int token)
488                 {
489                         return GetCustomAttributes(token, null);
490                 }
491
492                 internal abstract Type GetModuleType();
493
494                 internal abstract ByteReader GetBlob(int blobIndex);
495
496                 internal virtual IList<CustomAttributeData> GetCustomAttributesData(Type attributeType)
497                 {
498                         return GetCustomAttributes(0x00000001, attributeType);
499                 }
500
501                 internal List<CustomAttributeData> GetCustomAttributes(int metadataToken, Type attributeType)
502                 {
503                         List<CustomAttributeData> list = new List<CustomAttributeData>();
504                         if ((sortedTableMask & (1UL << CustomAttributeTable.Index)) == 0)
505                         {
506                                 for (int i = 0; i < CustomAttribute.RowCount; i++)
507                                 {
508                                         if (CustomAttribute.records[i].Parent == metadataToken)
509                                         {
510                                                 if (attributeType == null)
511                                                 {
512                                                         list.Add(new CustomAttributeData(this, i));
513                                                 }
514                                                 else
515                                                 {
516                                                         ConstructorInfo constructor = (ConstructorInfo)ResolveMethod(CustomAttribute.records[i].Type);
517                                                         if (attributeType.IsAssignableFrom(constructor.DeclaringType))
518                                                         {
519                                                                 list.Add(new CustomAttributeData(this, i));
520                                                         }
521                                                 }
522                                         }
523                                 }
524                         }
525                         else
526                         {
527                                 // do a binary search (on the rid part of the token)
528                                 CustomAttributeTable.Record rec = new CustomAttributeTable.Record();
529                                 rec.Parent = metadataToken;
530                                 int index = Array.BinarySearch(CustomAttribute.records, 0, CustomAttribute.RowCount, rec, BinarySearch.Comparer);
531                                 if (index >= 0)
532                                 {
533                                         while (index > 0 && (CustomAttribute.records[index - 1].Parent & 0xFFFFFF) == (metadataToken & 0xFFFFFF))
534                                         {
535                                                 index--;
536                                         }
537                                         for (; index < CustomAttribute.RowCount && (CustomAttribute.records[index].Parent & 0xFFFFFF) == (metadataToken & 0xFFFFFF); index++)
538                                         {
539                                                 if (CustomAttribute.records[index].Parent == metadataToken)
540                                                 {
541                                                         if (attributeType == null)
542                                                         {
543                                                                 list.Add(new CustomAttributeData(this, index));
544                                                         }
545                                                         else
546                                                         {
547                                                                 ConstructorInfo constructor = (ConstructorInfo)ResolveMethod(CustomAttribute.records[index].Type);
548                                                                 if (attributeType.IsAssignableFrom(constructor.DeclaringType))
549                                                                 {
550                                                                         list.Add(new CustomAttributeData(this, index));
551                                                                 }
552                                                         }
553                                                 }
554                                         }
555                                 }
556                         }
557                         return list;
558                 }
559
560                 private sealed class BinarySearch : IComparer<CustomAttributeTable.Record>
561                 {
562                         internal static readonly BinarySearch Comparer = new BinarySearch();
563
564                         public int Compare(CustomAttributeTable.Record x, CustomAttributeTable.Record y)
565                         {
566                                 return (x.Parent & 0xFFFFFF).CompareTo(y.Parent & 0xFFFFFF);
567                         }
568                 }
569
570                 internal IList<CustomAttributeData> GetDeclarativeSecurity(int metadataToken)
571                 {
572                         List<CustomAttributeData> list = new List<CustomAttributeData>();
573                         // TODO use binary search?
574                         for (int i = 0; i < DeclSecurity.records.Length; i++)
575                         {
576                                 if (DeclSecurity.records[i].Parent == metadataToken)
577                                 {
578                                         CustomAttributeData.ReadDeclarativeSecurity(this, i, list);
579                                 }
580                         }
581                         return list;
582                 }
583
584                 internal virtual void Dispose()
585                 {
586                 }
587
588                 internal virtual void ExportTypes(int fileToken, IKVM.Reflection.Emit.ModuleBuilder manifestModule)
589                 {
590                 }
591         }
592
593         abstract class NonPEModule : Module
594         {
595                 protected NonPEModule(Universe universe)
596                         : base(universe)
597                 {
598                 }
599
600                 protected virtual Exception InvalidOperationException()
601                 {
602                         return new InvalidOperationException();
603                 }
604
605                 protected virtual Exception NotSupportedException()
606                 {
607                         return new NotSupportedException();
608                 }
609
610                 protected virtual Exception ArgumentOutOfRangeException()
611                 {
612                         return new ArgumentOutOfRangeException();
613                 }
614
615                 internal sealed override Type GetModuleType()
616                 {
617                         throw InvalidOperationException();
618                 }
619
620                 internal sealed override ByteReader GetBlob(int blobIndex)
621                 {
622                         throw InvalidOperationException();
623                 }
624
625                 public sealed override AssemblyName[] __GetReferencedAssemblies()
626                 {
627                         throw NotSupportedException();
628                 }
629
630                 public sealed override string[] __GetReferencedModules()
631                 {
632                         throw NotSupportedException();
633                 }
634
635                 public override Type[] __GetReferencedTypes()
636                 {
637                         throw NotSupportedException();
638                 }
639
640                 public override Type[] __GetExportedTypes()
641                 {
642                         throw NotSupportedException();
643                 }
644
645                 protected sealed override long GetImageBaseImpl()
646                 {
647                         throw NotSupportedException();
648                 }
649
650                 public sealed override Type ResolveType(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
651                 {
652                         throw ArgumentOutOfRangeException();
653                 }
654
655                 public sealed override MethodBase ResolveMethod(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
656                 {
657                         throw ArgumentOutOfRangeException();
658                 }
659
660                 public sealed override FieldInfo ResolveField(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
661                 {
662                         throw ArgumentOutOfRangeException();
663                 }
664
665                 public sealed override MemberInfo ResolveMember(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
666                 {
667                         throw ArgumentOutOfRangeException();
668                 }
669
670                 public sealed override string ResolveString(int metadataToken)
671                 {
672                         throw ArgumentOutOfRangeException();
673                 }
674
675                 public sealed override Type[] __ResolveOptionalParameterTypes(int metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments, out CustomModifiers[] customModifiers)
676                 {
677                         throw ArgumentOutOfRangeException();
678                 }
679         }
680
681         public delegate bool TypeFilter(Type m, object filterCriteria);
682         public delegate bool MemberFilter(MemberInfo m, object filterCriteria);
683 }