Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / mscorlib / system / reflection / mdimport.cs
blobf2f0c70edcead691026bdbb4b7412478d571e53c
1 // ==++==
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // ==--==
6 // <OWNER>Microsoft</OWNER>
7 //
9 using System;
10 using System.Reflection;
11 using System.Globalization;
12 using System.Threading;
13 using System.Diagnostics;
14 using System.Security.Permissions;
15 using System.Collections;
16 using System.Runtime.CompilerServices;
17 using System.Security;
18 using System.Text;
19 using System.Runtime.InteropServices;
20 using System.Configuration.Assemblies;
21 using System.Runtime.Versioning;
22 using System.Diagnostics.Contracts;
24 namespace System.Reflection
26 [Serializable]
27 internal enum CorElementType : byte
29 End = 0x00,
30 Void = 0x01,
31 Boolean = 0x02,
32 Char = 0x03,
33 I1 = 0x04,
34 U1 = 0x05,
35 I2 = 0x06,
36 U2 = 0x07,
37 I4 = 0x08,
38 U4 = 0x09,
39 I8 = 0x0A,
40 U8 = 0x0B,
41 R4 = 0x0C,
42 R8 = 0x0D,
43 String = 0x0E,
44 Ptr = 0x0F,
45 ByRef = 0x10,
46 ValueType = 0x11,
47 Class = 0x12,
48 Var = 0x13,
49 Array = 0x14,
50 GenericInst = 0x15,
51 TypedByRef = 0x16,
52 I = 0x18,
53 U = 0x19,
54 FnPtr = 0x1B,
55 Object = 0x1C,
56 SzArray = 0x1D,
57 MVar = 0x1E,
58 CModReqd = 0x1F,
59 CModOpt = 0x20,
60 Internal = 0x21,
61 Max = 0x22,
62 Modifier = 0x40,
63 Sentinel = 0x41,
64 Pinned = 0x45,
67 [Serializable]
68 [Flags()]
69 internal enum MdSigCallingConvention: byte
71 CallConvMask = 0x0f, // Calling convention is bottom 4 bits
73 Default = 0x00,
74 C = 0x01,
75 StdCall = 0x02,
76 ThisCall = 0x03,
77 FastCall = 0x04,
78 Vararg = 0x05,
79 Field = 0x06,
80 LocalSig = 0x07,
81 Property = 0x08,
82 Unmgd = 0x09,
83 GenericInst = 0x0a, // generic method instantiation
85 Generic = 0x10, // Generic method sig with explicit number of type arguments (precedes ordinary parameter count)
86 HasThis = 0x20, // Top bit indicates a 'this' parameter
87 ExplicitThis = 0x40, // This parameter is explicitly in the signature
91 [Serializable]
92 [Flags()]
93 internal enum PInvokeAttributes
95 NoMangle = 0x0001,
98 CharSetMask = 0x0006,
99 CharSetNotSpec = 0x0000,
100 CharSetAnsi = 0x0002,
101 CharSetUnicode = 0x0004,
102 CharSetAuto = 0x0006,
105 BestFitUseAssem = 0x0000,
106 BestFitEnabled = 0x0010,
107 BestFitDisabled = 0x0020,
108 BestFitMask = 0x0030,
110 ThrowOnUnmappableCharUseAssem = 0x0000,
111 ThrowOnUnmappableCharEnabled = 0x1000,
112 ThrowOnUnmappableCharDisabled = 0x2000,
113 ThrowOnUnmappableCharMask = 0x3000,
115 SupportsLastError = 0x0040,
117 CallConvMask = 0x0700,
118 CallConvWinapi = 0x0100,
119 CallConvCdecl = 0x0200,
120 CallConvStdcall = 0x0300,
121 CallConvThiscall = 0x0400,
122 CallConvFastcall = 0x0500,
124 MaxValue = 0xFFFF,
128 [Serializable]
129 [Flags()]
130 internal enum MethodSemanticsAttributes
132 Setter = 0x0001,
133 Getter = 0x0002,
134 Other = 0x0004,
135 AddOn = 0x0008,
136 RemoveOn = 0x0010,
137 Fire = 0x0020,
141 [Serializable]
142 internal enum MetadataTokenType
144 Module = 0x00000000,
145 TypeRef = 0x01000000,
146 TypeDef = 0x02000000,
147 FieldDef = 0x04000000,
148 MethodDef = 0x06000000,
149 ParamDef = 0x08000000,
150 InterfaceImpl = 0x09000000,
151 MemberRef = 0x0a000000,
152 CustomAttribute = 0x0c000000,
153 Permission = 0x0e000000,
154 Signature = 0x11000000,
155 Event = 0x14000000,
156 Property = 0x17000000,
157 ModuleRef = 0x1a000000,
158 TypeSpec = 0x1b000000,
159 Assembly = 0x20000000,
160 AssemblyRef = 0x23000000,
161 File = 0x26000000,
162 ExportedType = 0x27000000,
163 ManifestResource = 0x28000000,
164 GenericPar = 0x2a000000,
165 MethodSpec = 0x2b000000,
166 String = 0x70000000,
167 Name = 0x71000000,
168 BaseType = 0x72000000,
169 Invalid = 0x7FFFFFFF,
171 #if !MONO
172 [Serializable]
173 internal struct ConstArray
175 public IntPtr Signature { get { return m_constArray; } }
176 public int Length { get { return m_length; } }
177 public byte this[int index]
179 [System.Security.SecuritySafeCritical] // auto-generated
182 if (index < 0 || index >= m_length)
183 throw new IndexOutOfRangeException();
184 Contract.EndContractBlock();
186 unsafe
188 return ((byte*)m_constArray.ToPointer())[index];
193 // Keep the definition in sync with vm\ManagedMdImport.hpp
194 internal int m_length;
195 internal IntPtr m_constArray;
198 [Serializable]
199 internal struct MetadataToken
201 #region Implicit Cast Operators
202 public static implicit operator int(MetadataToken token) { return token.Value; }
203 public static implicit operator MetadataToken(int token) { return new MetadataToken(token); }
204 #endregion
206 #region Public Static Members
207 public static bool IsTokenOfType(int token, params MetadataTokenType[] types)
209 for (int i = 0; i < types.Length; i++)
211 if ((int)(token & 0xFF000000) == (int)types[i])
212 return true;
215 return false;
218 public static bool IsNullToken(int token)
220 return (token & 0x00FFFFFF) == 0;
222 #endregion
224 #region Public Data Members
225 public int Value;
226 #endregion
228 #region Constructor
229 public MetadataToken(int token) { Value = token; }
230 #endregion
232 #region Public Members
233 public bool IsGlobalTypeDefToken { get { return (Value == 0x02000001); } }
234 public MetadataTokenType TokenType { get { return (MetadataTokenType)(Value & 0xFF000000); } }
235 public bool IsTypeRef { get { return TokenType == MetadataTokenType.TypeRef; } }
236 public bool IsTypeDef { get { return TokenType == MetadataTokenType.TypeDef; } }
237 public bool IsFieldDef { get { return TokenType == MetadataTokenType.FieldDef; } }
238 public bool IsMethodDef { get { return TokenType == MetadataTokenType.MethodDef; } }
239 public bool IsMemberRef { get { return TokenType == MetadataTokenType.MemberRef; } }
240 public bool IsEvent { get { return TokenType == MetadataTokenType.Event; } }
241 public bool IsProperty { get { return TokenType == MetadataTokenType.Property; } }
242 public bool IsParamDef { get { return TokenType == MetadataTokenType.ParamDef; } }
243 public bool IsTypeSpec { get { return TokenType == MetadataTokenType.TypeSpec; } }
244 public bool IsMethodSpec { get { return TokenType == MetadataTokenType.MethodSpec; } }
245 public bool IsString { get { return TokenType == MetadataTokenType.String; } }
246 public bool IsSignature { get { return TokenType == MetadataTokenType.Signature; } }
247 public bool IsModule { get { return TokenType == MetadataTokenType.Module; } }
248 public bool IsAssembly { get { return TokenType == MetadataTokenType.Assembly; } }
249 public bool IsGenericPar { get { return TokenType == MetadataTokenType.GenericPar; } }
250 #endregion
252 #region Object Overrides
253 public override string ToString() { return String.Format(CultureInfo.InvariantCulture, "0x{0:x8}", Value); }
254 #endregion
257 internal unsafe struct MetadataEnumResult
259 // Keep the definition in sync with vm\ManagedMdImport.hpp
260 private int[] largeResult;
261 private int length;
262 private fixed int smallResult[16];
264 public int Length
268 return length;
272 public int this[int index]
274 [System.Security.SecurityCritical]
277 Contract.Requires(0 <= index && index < Length);
278 if (largeResult != null)
279 return largeResult[index];
281 fixed (int* p = smallResult)
282 return p[index];
287 internal struct MetadataImport
289 #region Private Data Members
290 private IntPtr m_metadataImport2;
291 private object m_keepalive;
292 #endregion
294 #region Override methods from Object
295 internal static readonly MetadataImport EmptyImport = new MetadataImport((IntPtr)0, null);
297 public override int GetHashCode()
299 return ValueType.GetHashCodeOfPtr(m_metadataImport2);
302 public override bool Equals(object obj)
304 if(!(obj is MetadataImport))
305 return false;
306 return Equals((MetadataImport)obj);
309 private bool Equals(MetadataImport import)
311 return import.m_metadataImport2 == m_metadataImport2;
314 #endregion
316 #region Static Members
317 [System.Security.SecurityCritical] // auto-generated
318 [ResourceExposure(ResourceScope.None)]
319 [MethodImplAttribute(MethodImplOptions.InternalCall)]
320 private static extern void _GetMarshalAs(IntPtr pNativeType, int cNativeType, out int unmanagedType, out int safeArraySubType, out string safeArrayUserDefinedSubType,
321 out int arraySubType, out int sizeParamIndex, out int sizeConst, out string marshalType, out string marshalCookie,
322 out int iidParamIndex);
323 [System.Security.SecurityCritical] // auto-generated
324 internal static void GetMarshalAs(ConstArray nativeType,
325 out UnmanagedType unmanagedType, out VarEnum safeArraySubType, out string safeArrayUserDefinedSubType,
326 out UnmanagedType arraySubType, out int sizeParamIndex, out int sizeConst, out string marshalType, out string marshalCookie,
327 out int iidParamIndex)
329 int _unmanagedType, _safeArraySubType, _arraySubType;
331 _GetMarshalAs(nativeType.Signature, (int)nativeType.Length,
332 out _unmanagedType, out _safeArraySubType, out safeArrayUserDefinedSubType,
333 out _arraySubType, out sizeParamIndex, out sizeConst, out marshalType, out marshalCookie,
334 out iidParamIndex);
335 unmanagedType = (UnmanagedType)_unmanagedType;
336 safeArraySubType = (VarEnum)_safeArraySubType;
337 arraySubType = (UnmanagedType)_arraySubType;
339 #endregion
341 #region Internal Static Members
342 internal static void ThrowError(int hResult)
344 throw new MetadataException(hResult);
346 #endregion
348 #region Constructor
349 internal MetadataImport(IntPtr metadataImport2, object keepalive)
351 m_metadataImport2 = metadataImport2;
352 m_keepalive = keepalive;
354 #endregion
356 #region FCalls
357 [System.Security.SecurityCritical] // auto-generated
358 [ResourceExposure(ResourceScope.None)]
359 [MethodImplAttribute (MethodImplOptions.InternalCall)]
360 private unsafe static extern void _Enum(IntPtr scope, int type, int parent, out MetadataEnumResult result);
362 [System.Security.SecurityCritical] // auto-generated
363 public unsafe void Enum(MetadataTokenType type, int parent, out MetadataEnumResult result)
365 _Enum(m_metadataImport2, (int)type, parent, out result);
368 [System.Security.SecurityCritical] // auto-generated
369 public unsafe void EnumNestedTypes(int mdTypeDef, out MetadataEnumResult result)
371 Enum(MetadataTokenType.TypeDef, mdTypeDef, out result);
374 [System.Security.SecurityCritical] // auto-generated
375 public unsafe void EnumCustomAttributes(int mdToken, out MetadataEnumResult result)
377 Enum(MetadataTokenType.CustomAttribute, mdToken, out result);
380 [System.Security.SecurityCritical] // auto-generated
381 public unsafe void EnumParams(int mdMethodDef, out MetadataEnumResult result)
383 Enum(MetadataTokenType.ParamDef, mdMethodDef, out result);
386 [System.Security.SecurityCritical] // auto-generated
387 public unsafe void EnumFields(int mdTypeDef, out MetadataEnumResult result)
389 Enum(MetadataTokenType.FieldDef, mdTypeDef, out result);
392 [System.Security.SecurityCritical] // auto-generated
393 public unsafe void EnumProperties(int mdTypeDef, out MetadataEnumResult result)
395 Enum(MetadataTokenType.Property, mdTypeDef, out result);
398 [System.Security.SecurityCritical] // auto-generated
399 public unsafe void EnumEvents(int mdTypeDef, out MetadataEnumResult result)
401 Enum(MetadataTokenType.Event, mdTypeDef, out result);
404 [System.Security.SecurityCritical] // auto-generated
405 [ResourceExposure(ResourceScope.None)]
406 [MethodImplAttribute (MethodImplOptions.InternalCall)]
407 private static extern String _GetDefaultValue(IntPtr scope, int mdToken, out long value, out int length, out int corElementType);
408 [System.Security.SecurityCritical] // auto-generated
409 public String GetDefaultValue(int mdToken, out long value, out int length, out CorElementType corElementType)
411 int _corElementType;
412 String stringVal;
413 stringVal = _GetDefaultValue(m_metadataImport2, mdToken, out value, out length, out _corElementType);
414 corElementType = (CorElementType)_corElementType;
415 return stringVal;
418 [System.Security.SecurityCritical] // auto-generated
419 [ResourceExposure(ResourceScope.None)]
420 [MethodImplAttribute (MethodImplOptions.InternalCall)]
421 private static unsafe extern void _GetUserString(IntPtr scope, int mdToken, void** name, out int length);
422 [System.Security.SecurityCritical] // auto-generated
423 public unsafe String GetUserString(int mdToken)
425 void* name;
426 int length;
427 _GetUserString(m_metadataImport2, mdToken, &name, out length);
429 if (name == null)
430 return null;
432 char[] c = new char[length];
433 for (int i = 0; i < length; i ++)
435 #if ALIGN_ACCESS
436 c[i] = (char)Marshal.ReadInt16( (IntPtr) (((char*)name) + i) );
437 #else
438 c[i] = ((char*)name)[i];
439 #endif
442 return new String(c);
445 [System.Security.SecurityCritical] // auto-generated
446 [ResourceExposure(ResourceScope.None)]
447 [MethodImplAttribute (MethodImplOptions.InternalCall)]
448 private static unsafe extern void _GetName(IntPtr scope, int mdToken, void** name);
449 [System.Security.SecurityCritical] // auto-generated
450 public unsafe Utf8String GetName(int mdToken)
452 void* name;
453 _GetName(m_metadataImport2, mdToken, &name);
455 return new Utf8String(name);
458 [System.Security.SecurityCritical] // auto-generated
459 [ResourceExposure(ResourceScope.None)]
460 [MethodImplAttribute (MethodImplOptions.InternalCall)]
461 private static unsafe extern void _GetNamespace(IntPtr scope, int mdToken, void** namesp);
462 [System.Security.SecurityCritical] // auto-generated
463 public unsafe Utf8String GetNamespace(int mdToken)
465 void* namesp;
466 _GetNamespace(m_metadataImport2, mdToken, &namesp);
468 return new Utf8String(namesp);
471 [System.Security.SecurityCritical] // auto-generated
472 [ResourceExposure(ResourceScope.None)]
473 [MethodImplAttribute (MethodImplOptions.InternalCall)]
474 private unsafe static extern void _GetEventProps(IntPtr scope, int mdToken, void** name, out int eventAttributes);
475 [System.Security.SecurityCritical] // auto-generated
476 public unsafe void GetEventProps(int mdToken, out void* name, out EventAttributes eventAttributes)
478 int _eventAttributes;
479 void* _name;
480 _GetEventProps(m_metadataImport2, mdToken, &_name, out _eventAttributes);
481 name = _name;
482 eventAttributes = (EventAttributes)_eventAttributes;
485 [System.Security.SecurityCritical] // auto-generated
486 [ResourceExposure(ResourceScope.None)]
487 [MethodImplAttribute (MethodImplOptions.InternalCall)]
488 private static extern void _GetFieldDefProps(IntPtr scope, int mdToken, out int fieldAttributes);
489 [System.Security.SecurityCritical] // auto-generated
490 public void GetFieldDefProps(int mdToken, out FieldAttributes fieldAttributes)
492 int _fieldAttributes;
493 _GetFieldDefProps(m_metadataImport2, mdToken, out _fieldAttributes);
494 fieldAttributes = (FieldAttributes)_fieldAttributes;
497 [System.Security.SecurityCritical] // auto-generated
498 [ResourceExposure(ResourceScope.None)]
499 [MethodImplAttribute (MethodImplOptions.InternalCall)]
500 private unsafe static extern void _GetPropertyProps(IntPtr scope,
501 int mdToken, void** name, out int propertyAttributes, out ConstArray signature);
502 [System.Security.SecurityCritical] // auto-generated
503 public unsafe void GetPropertyProps(int mdToken, out void* name, out PropertyAttributes propertyAttributes, out ConstArray signature)
505 int _propertyAttributes;
506 void* _name;
507 _GetPropertyProps(m_metadataImport2, mdToken, &_name, out _propertyAttributes, out signature);
508 name = _name;
509 propertyAttributes = (PropertyAttributes)_propertyAttributes;
512 [System.Security.SecurityCritical] // auto-generated
513 [ResourceExposure(ResourceScope.None)]
514 [MethodImplAttribute (MethodImplOptions.InternalCall)]
515 private static extern void _GetParentToken(IntPtr scope,
516 int mdToken, out int tkParent);
517 [System.Security.SecurityCritical] // auto-generated
518 public int GetParentToken(int tkToken)
520 int tkParent;
521 _GetParentToken(m_metadataImport2, tkToken, out tkParent);
522 return tkParent;
525 [System.Security.SecurityCritical] // auto-generated
526 [ResourceExposure(ResourceScope.None)]
527 [MethodImplAttribute(MethodImplOptions.InternalCall)]
528 private static extern void _GetParamDefProps(IntPtr scope,
529 int parameterToken, out int sequence, out int attributes);
530 [System.Security.SecurityCritical] // auto-generated
531 public void GetParamDefProps(int parameterToken, out int sequence, out ParameterAttributes attributes)
533 int _attributes;
535 _GetParamDefProps(m_metadataImport2, parameterToken, out sequence, out _attributes);
537 attributes = (ParameterAttributes)_attributes;
540 [System.Security.SecurityCritical] // auto-generated
541 [ResourceExposure(ResourceScope.None)]
542 [MethodImplAttribute(MethodImplOptions.InternalCall)]
543 private static extern void _GetGenericParamProps(IntPtr scope,
544 int genericParameter,
545 out int flags);
547 [System.Security.SecurityCritical] // auto-generated
548 public void GetGenericParamProps(
549 int genericParameter,
550 out GenericParameterAttributes attributes)
552 int _attributes;
553 _GetGenericParamProps(m_metadataImport2, genericParameter, out _attributes);
554 attributes = (GenericParameterAttributes)_attributes;
557 [System.Security.SecurityCritical] // auto-generated
558 [ResourceExposure(ResourceScope.None)]
559 [MethodImplAttribute(MethodImplOptions.InternalCall)]
560 private static extern void _GetScopeProps(IntPtr scope,
561 out Guid mvid);
563 [System.Security.SecurityCritical] // auto-generated
564 public void GetScopeProps(
565 out Guid mvid)
567 _GetScopeProps(m_metadataImport2, out mvid);
571 [System.Security.SecurityCritical] // auto-generated
572 public ConstArray GetMethodSignature(MetadataToken token)
574 if (token.IsMemberRef)
575 return GetMemberRefProps(token);
577 return GetSigOfMethodDef(token);
580 [System.Security.SecurityCritical] // auto-generated
581 [ResourceExposure(ResourceScope.None)]
582 [MethodImplAttribute(MethodImplOptions.InternalCall)]
583 private static extern void _GetSigOfMethodDef(IntPtr scope,
584 int methodToken,
585 ref ConstArray signature);
587 [System.Security.SecurityCritical] // auto-generated
588 public ConstArray GetSigOfMethodDef(int methodToken)
590 ConstArray signature = new ConstArray();
592 _GetSigOfMethodDef(m_metadataImport2, methodToken, ref signature);
594 return signature;
597 [System.Security.SecurityCritical] // auto-generated
598 [ResourceExposure(ResourceScope.None)]
599 [MethodImplAttribute(MethodImplOptions.InternalCall)]
600 private static extern void _GetSignatureFromToken(IntPtr scope,
601 int methodToken,
602 ref ConstArray signature);
604 [System.Security.SecurityCritical] // auto-generated
605 public ConstArray GetSignatureFromToken(int token)
607 ConstArray signature = new ConstArray();
609 _GetSignatureFromToken(m_metadataImport2, token, ref signature);
611 return signature;
614 [System.Security.SecurityCritical] // auto-generated
615 [ResourceExposure(ResourceScope.None)]
616 [MethodImplAttribute(MethodImplOptions.InternalCall)]
617 private static extern void _GetMemberRefProps(IntPtr scope,
618 int memberTokenRef,
619 out ConstArray signature);
621 [System.Security.SecurityCritical] // auto-generated
622 public ConstArray GetMemberRefProps(int memberTokenRef)
624 ConstArray signature = new ConstArray();
626 _GetMemberRefProps(m_metadataImport2, memberTokenRef, out signature);
628 return signature;
631 [System.Security.SecurityCritical] // auto-generated
632 [ResourceExposure(ResourceScope.None)]
633 [MethodImplAttribute(MethodImplOptions.InternalCall)]
634 private static extern void _GetCustomAttributeProps(IntPtr scope,
635 int customAttributeToken,
636 out int constructorToken,
637 out ConstArray signature);
639 [System.Security.SecurityCritical] // auto-generated
640 public void GetCustomAttributeProps(
641 int customAttributeToken,
642 out int constructorToken,
643 out ConstArray signature)
645 _GetCustomAttributeProps(m_metadataImport2, customAttributeToken,
646 out constructorToken, out signature);
649 [System.Security.SecurityCritical] // auto-generated
650 [ResourceExposure(ResourceScope.None)]
651 [MethodImplAttribute(MethodImplOptions.InternalCall)]
652 private static extern void _GetClassLayout(IntPtr scope,
653 int typeTokenDef, out int packSize, out int classSize);
654 [System.Security.SecurityCritical] // auto-generated
655 public void GetClassLayout(
656 int typeTokenDef,
657 out int packSize,
658 out int classSize)
660 _GetClassLayout(m_metadataImport2, typeTokenDef, out packSize, out classSize);
663 [System.Security.SecurityCritical] // auto-generated
664 [ResourceExposure(ResourceScope.None)]
665 [MethodImplAttribute(MethodImplOptions.InternalCall)]
666 private static extern bool _GetFieldOffset(IntPtr scope,
667 int typeTokenDef, int fieldTokenDef, out int offset);
668 [System.Security.SecurityCritical] // auto-generated
669 public bool GetFieldOffset(
670 int typeTokenDef,
671 int fieldTokenDef,
672 out int offset)
674 return _GetFieldOffset(m_metadataImport2, typeTokenDef, fieldTokenDef, out offset);
677 [System.Security.SecurityCritical] // auto-generated
678 [ResourceExposure(ResourceScope.None)]
679 [MethodImplAttribute(MethodImplOptions.InternalCall)]
680 private static extern void _GetSigOfFieldDef(IntPtr scope,
681 int fieldToken,
682 ref ConstArray fieldMarshal);
684 [System.Security.SecurityCritical] // auto-generated
685 public ConstArray GetSigOfFieldDef(int fieldToken)
687 ConstArray fieldMarshal = new ConstArray();
689 _GetSigOfFieldDef(m_metadataImport2, fieldToken, ref fieldMarshal);
691 return fieldMarshal;
694 [System.Security.SecurityCritical] // auto-generated
695 [ResourceExposure(ResourceScope.None)]
696 [MethodImplAttribute(MethodImplOptions.InternalCall)]
697 private static extern void _GetFieldMarshal(IntPtr scope,
698 int fieldToken,
699 ref ConstArray fieldMarshal);
701 [System.Security.SecurityCritical] // auto-generated
702 public ConstArray GetFieldMarshal(int fieldToken)
704 ConstArray fieldMarshal = new ConstArray();
706 _GetFieldMarshal(m_metadataImport2, fieldToken, ref fieldMarshal);
708 return fieldMarshal;
711 [System.Security.SecurityCritical] // auto-generated
712 [ResourceExposure(ResourceScope.None)]
713 [MethodImplAttribute(MethodImplOptions.InternalCall)]
714 private unsafe static extern void _GetPInvokeMap(IntPtr scope,
715 int token,
716 out int attributes,
717 void** importName,
718 void** importDll);
720 [System.Security.SecurityCritical] // auto-generated
721 public unsafe void GetPInvokeMap(
722 int token,
723 out PInvokeAttributes attributes,
724 out String importName,
725 out String importDll)
727 int _attributes;
728 void* _importName, _importDll;
729 _GetPInvokeMap(m_metadataImport2, token, out _attributes, &_importName, &_importDll);
730 importName = new Utf8String(_importName).ToString();
731 importDll = new Utf8String(_importDll).ToString();
733 attributes = (PInvokeAttributes)_attributes;
736 [System.Security.SecurityCritical] // auto-generated
737 [ResourceExposure(ResourceScope.None)]
738 [MethodImplAttribute(MethodImplOptions.InternalCall)]
739 private static extern bool _IsValidToken(IntPtr scope, int token);
740 [System.Security.SecurityCritical] // auto-generated
741 public bool IsValidToken(int token)
743 return _IsValidToken(m_metadataImport2, token);
745 #endregion
749 internal class MetadataException : Exception
751 private int m_hr;
752 internal MetadataException(int hr) { m_hr = hr; }
754 public override string ToString()
756 return String.Format(CultureInfo.CurrentCulture, "MetadataException HResult = {0:x}.", m_hr);
759 #endif