| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.Reflection.Metadata.Ecma335 |
| | | 5 | | { |
| | | 6 | | public static class MetadataTokens |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Maximum number of tables that can be present in Ecma335 metadata. |
| | | 10 | | /// </summary> |
| | 0 | 11 | | public static readonly int TableCount = 64; // headers use 64bit table masks |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Maximum number of tables that can be present in Ecma335 metadata. |
| | | 15 | | /// </summary> |
| | 0 | 16 | | public static readonly int HeapCount = HeapIndexExtensions.Count; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Returns the row number of a metadata table entry that corresponds |
| | | 20 | | /// to the specified <paramref name="handle"/> in the context of <paramref name="reader"/>. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <returns>One based row number.</returns> |
| | | 23 | | /// <exception cref="ArgumentException">The <paramref name="handle"/> is not a valid metadata table handle.</exc |
| | | 24 | | public static int GetRowNumber(this MetadataReader reader, EntityHandle handle) |
| | 0 | 25 | | { |
| | 0 | 26 | | if (handle.IsVirtual) |
| | 0 | 27 | | { |
| | 0 | 28 | | return MapVirtualHandleRowId(reader, handle); |
| | | 29 | | } |
| | | 30 | | |
| | 0 | 31 | | return handle.RowId; |
| | 0 | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Returns the offset of metadata heap data that corresponds |
| | | 36 | | /// to the specified <paramref name="handle"/> in the context of <paramref name="reader"/>. |
| | | 37 | | /// </summary> |
| | | 38 | | /// <returns>Zero based offset, or -1 if <paramref name="handle"/> isn't a metadata heap handle.</returns> |
| | | 39 | | /// <exception cref="NotSupportedException">The operation is not supported for the specified <paramref name="han |
| | | 40 | | /// <exception cref="ArgumentException">The <paramref name="handle"/> is invalid.</exception> |
| | | 41 | | public static int GetHeapOffset(this MetadataReader reader, Handle handle) |
| | 0 | 42 | | { |
| | 0 | 43 | | if (!handle.IsHeapHandle) |
| | 0 | 44 | | { |
| | 0 | 45 | | Throw.HeapHandleRequired(); |
| | | 46 | | } |
| | | 47 | | |
| | 0 | 48 | | if (handle.IsVirtual) |
| | 0 | 49 | | { |
| | 0 | 50 | | return MapVirtualHandleRowId(reader, handle); |
| | | 51 | | } |
| | | 52 | | |
| | 0 | 53 | | return handle.Offset; |
| | 0 | 54 | | } |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Returns the metadata token of the specified <paramref name="handle"/> in the context of <paramref name="read |
| | | 58 | | /// </summary> |
| | | 59 | | /// <returns>Metadata token.</returns> |
| | | 60 | | /// <exception cref="NotSupportedException">The operation is not supported for the specified <paramref name="han |
| | | 61 | | public static int GetToken(this MetadataReader reader, EntityHandle handle) |
| | 0 | 62 | | { |
| | 0 | 63 | | if (handle.IsVirtual) |
| | 0 | 64 | | { |
| | 0 | 65 | | return (int)handle.Type | MapVirtualHandleRowId(reader, handle); |
| | | 66 | | } |
| | | 67 | | |
| | 0 | 68 | | return handle.Token; |
| | 0 | 69 | | } |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Returns the metadata token of the specified <paramref name="handle"/> in the context of <paramref name="read |
| | | 73 | | /// </summary> |
| | | 74 | | /// <returns>Metadata token.</returns> |
| | | 75 | | /// <exception cref="ArgumentException"> |
| | | 76 | | /// Handle represents a metadata entity that doesn't have a token. |
| | | 77 | | /// A token can only be retrieved for a metadata table handle or a heap handle of type <see cref="HandleKind.Use |
| | | 78 | | /// </exception> |
| | | 79 | | /// <exception cref="NotSupportedException">The operation is not supported for the specified <paramref name="han |
| | | 80 | | public static int GetToken(this MetadataReader reader, Handle handle) |
| | 0 | 81 | | { |
| | 0 | 82 | | if (!handle.IsEntityOrUserStringHandle) |
| | 0 | 83 | | { |
| | 0 | 84 | | Throw.EntityOrUserStringHandleRequired(); |
| | | 85 | | } |
| | | 86 | | |
| | 0 | 87 | | if (handle.IsVirtual) |
| | 0 | 88 | | { |
| | 0 | 89 | | return (int)handle.EntityHandleType | MapVirtualHandleRowId(reader, handle); |
| | | 90 | | } |
| | | 91 | | |
| | 0 | 92 | | return handle.Token; |
| | 0 | 93 | | } |
| | | 94 | | |
| | | 95 | | private static int MapVirtualHandleRowId(MetadataReader reader, Handle handle) |
| | 0 | 96 | | { |
| | 0 | 97 | | switch (handle.Kind) |
| | | 98 | | { |
| | | 99 | | case HandleKind.AssemblyReference: |
| | | 100 | | // pretend that virtual rows immediately follow real rows: |
| | 0 | 101 | | return reader.AssemblyRefTable.NumberOfNonVirtualRows + 1 + handle.RowId; |
| | | 102 | | |
| | | 103 | | case HandleKind.String: |
| | | 104 | | case HandleKind.Blob: |
| | | 105 | | // We could precalculate offsets for virtual strings and blobs as we are creating them |
| | | 106 | | // if we wanted to implement this. |
| | 0 | 107 | | throw new NotSupportedException(SR.CantGetOffsetForVirtualHeapHandle); |
| | | 108 | | |
| | | 109 | | default: |
| | 0 | 110 | | Throw.InvalidArgument_UnexpectedHandleKind(handle.Kind); |
| | | 111 | | return 0; |
| | | 112 | | } |
| | 0 | 113 | | } |
| | | 114 | | |
| | | 115 | | /// <summary> |
| | | 116 | | /// Returns the row number of a metadata table entry that corresponds |
| | | 117 | | /// to the specified <paramref name="handle"/>. |
| | | 118 | | /// </summary> |
| | | 119 | | /// <returns> |
| | | 120 | | /// One based row number, or -1 if <paramref name="handle"/> can only be interpreted in a context of a specific |
| | | 121 | | /// See <see cref="GetRowNumber(MetadataReader, EntityHandle)"/>. |
| | | 122 | | /// </returns> |
| | | 123 | | public static int GetRowNumber(EntityHandle handle) |
| | 0 | 124 | | { |
| | 0 | 125 | | return handle.IsVirtual ? -1 : handle.RowId; |
| | 0 | 126 | | } |
| | | 127 | | |
| | | 128 | | /// <summary> |
| | | 129 | | /// Returns the offset of metadata heap data that corresponds |
| | | 130 | | /// to the specified <paramref name="handle"/>. |
| | | 131 | | /// </summary> |
| | | 132 | | /// <returns> |
| | | 133 | | /// An offset in the corresponding heap, or -1 if <paramref name="handle"/> can only be interpreted in a context |
| | | 134 | | /// See <see cref="GetHeapOffset(MetadataReader, Handle)"/>. |
| | | 135 | | /// </returns> |
| | | 136 | | public static int GetHeapOffset(Handle handle) |
| | 0 | 137 | | { |
| | 0 | 138 | | if (!handle.IsHeapHandle) |
| | 0 | 139 | | { |
| | 0 | 140 | | Throw.HeapHandleRequired(); |
| | | 141 | | } |
| | | 142 | | |
| | 0 | 143 | | if (handle.IsVirtual) |
| | 0 | 144 | | { |
| | 0 | 145 | | return -1; |
| | | 146 | | } |
| | | 147 | | |
| | 0 | 148 | | return handle.Offset; |
| | 0 | 149 | | } |
| | | 150 | | |
| | | 151 | | /// <summary> |
| | | 152 | | /// Returns the offset of metadata heap data that corresponds |
| | | 153 | | /// to the specified <paramref name="handle"/>. |
| | | 154 | | /// </summary> |
| | | 155 | | /// <returns> |
| | | 156 | | /// Zero based offset, or -1 if <paramref name="handle"/> can only be interpreted in a context of a specific <se |
| | | 157 | | /// See <see cref="GetHeapOffset(MetadataReader, Handle)"/>. |
| | | 158 | | /// </returns> |
| | 0 | 159 | | public static int GetHeapOffset(BlobHandle handle) => handle.IsVirtual ? -1 : handle.GetHeapOffset(); |
| | | 160 | | |
| | | 161 | | /// <summary> |
| | | 162 | | /// Returns the offset of metadata heap data that corresponds |
| | | 163 | | /// to the specified <paramref name="handle"/>. |
| | | 164 | | /// </summary> |
| | | 165 | | /// <returns> |
| | | 166 | | /// 1-based index into the #Guid heap. Unlike other heaps, which are essentially byte arrays, the #Guid heap is |
| | | 167 | | /// </returns> |
| | 0 | 168 | | public static int GetHeapOffset(GuidHandle handle) => handle.Index; |
| | | 169 | | |
| | | 170 | | /// <summary> |
| | | 171 | | /// Returns the offset of metadata heap data that corresponds |
| | | 172 | | /// to the specified <paramref name="handle"/>. |
| | | 173 | | /// </summary> |
| | | 174 | | /// <returns> |
| | | 175 | | /// Zero based offset. |
| | | 176 | | /// </returns> |
| | 0 | 177 | | public static int GetHeapOffset(UserStringHandle handle) => handle.GetHeapOffset(); |
| | | 178 | | |
| | | 179 | | /// <summary> |
| | | 180 | | /// Returns the offset of metadata heap data that corresponds |
| | | 181 | | /// to the specified <paramref name="handle"/>. |
| | | 182 | | /// </summary> |
| | | 183 | | /// <returns> |
| | | 184 | | /// Zero based offset, or -1 if <paramref name="handle"/> can only be interpreted in a context of a specific <se |
| | | 185 | | /// See <see cref="GetHeapOffset(MetadataReader, Handle)"/>. |
| | | 186 | | /// </returns> |
| | 0 | 187 | | public static int GetHeapOffset(StringHandle handle) => handle.IsVirtual ? -1 : handle.GetHeapOffset(); |
| | | 188 | | |
| | | 189 | | /// <summary> |
| | | 190 | | /// Returns the metadata token of the specified <paramref name="handle"/>. |
| | | 191 | | /// </summary> |
| | | 192 | | /// <returns> |
| | | 193 | | /// Metadata token, or 0 if <paramref name="handle"/> can only be interpreted in a context of a specific <see cr |
| | | 194 | | /// See <see cref="GetToken(MetadataReader, Handle)"/>. |
| | | 195 | | /// </returns> |
| | | 196 | | /// <exception cref="ArgumentException"> |
| | | 197 | | /// Handle represents a metadata entity that doesn't have a token. |
| | | 198 | | /// A token can only be retrieved for a metadata table handle or a heap handle of type <see cref="HandleKind.Use |
| | | 199 | | /// </exception> |
| | | 200 | | public static int GetToken(Handle handle) |
| | 0 | 201 | | { |
| | 0 | 202 | | if (!handle.IsEntityOrUserStringHandle) |
| | 0 | 203 | | { |
| | 0 | 204 | | Throw.EntityOrUserStringHandleRequired(); |
| | | 205 | | } |
| | | 206 | | |
| | 0 | 207 | | if (handle.IsVirtual) |
| | 0 | 208 | | { |
| | 0 | 209 | | return 0; |
| | | 210 | | } |
| | | 211 | | |
| | 0 | 212 | | return handle.Token; |
| | 0 | 213 | | } |
| | | 214 | | |
| | | 215 | | /// <summary> |
| | | 216 | | /// Returns the metadata token of the specified <paramref name="handle"/>. |
| | | 217 | | /// </summary> |
| | | 218 | | /// <returns> |
| | | 219 | | /// Metadata token, or 0 if <paramref name="handle"/> can only be interpreted in a context of a specific <see cr |
| | | 220 | | /// See <see cref="GetToken(MetadataReader, EntityHandle)"/>. |
| | | 221 | | /// </returns> |
| | | 222 | | public static int GetToken(EntityHandle handle) |
| | 0 | 223 | | { |
| | 0 | 224 | | return handle.IsVirtual ? 0 : handle.Token; |
| | 0 | 225 | | } |
| | | 226 | | |
| | | 227 | | /// <summary> |
| | | 228 | | /// Gets the <see cref="TableIndex"/> of the table corresponding to the specified <see cref="HandleKind"/>. |
| | | 229 | | /// </summary> |
| | | 230 | | /// <param name="type">Handle type.</param> |
| | | 231 | | /// <param name="index">Table index.</param> |
| | | 232 | | /// <returns>True if the handle type corresponds to an Ecma335 or Portable PDB table, false otherwise.</returns> |
| | | 233 | | public static bool TryGetTableIndex(HandleKind type, out TableIndex index) |
| | 0 | 234 | | { |
| | | 235 | | // We don't have a HandleKind for PropertyMap, EventMap, MethodSemantics, *Ptr, AssemblyOS, etc. tables, |
| | | 236 | | // but one can get ahold of one by creating a handle from a token and getting its Kind. |
| | 0 | 237 | | if ((int)type < TableCount && ((1UL << (int)type) & (ulong)TableMask.AllTables) != 0) |
| | 0 | 238 | | { |
| | 0 | 239 | | index = (TableIndex)type; |
| | 0 | 240 | | return true; |
| | | 241 | | } |
| | | 242 | | |
| | 0 | 243 | | index = 0; |
| | 0 | 244 | | return false; |
| | 0 | 245 | | } |
| | | 246 | | |
| | | 247 | | /// <summary> |
| | | 248 | | /// Gets the <see cref="HeapIndex"/> of the heap corresponding to the specified <see cref="HandleKind"/>. |
| | | 249 | | /// </summary> |
| | | 250 | | /// <param name="type">Handle type.</param> |
| | | 251 | | /// <param name="index">Heap index.</param> |
| | | 252 | | /// <returns>True if the handle type corresponds to an Ecma335 heap, false otherwise.</returns> |
| | | 253 | | public static bool TryGetHeapIndex(HandleKind type, out HeapIndex index) |
| | 0 | 254 | | { |
| | 0 | 255 | | switch (type) |
| | | 256 | | { |
| | | 257 | | case HandleKind.UserString: |
| | 0 | 258 | | index = HeapIndex.UserString; |
| | 0 | 259 | | return true; |
| | | 260 | | |
| | | 261 | | case HandleKind.String: |
| | | 262 | | case HandleKind.NamespaceDefinition: |
| | 0 | 263 | | index = HeapIndex.String; |
| | 0 | 264 | | return true; |
| | | 265 | | |
| | | 266 | | case HandleKind.Blob: |
| | 0 | 267 | | index = HeapIndex.Blob; |
| | 0 | 268 | | return true; |
| | | 269 | | |
| | | 270 | | case HandleKind.Guid: |
| | 0 | 271 | | index = HeapIndex.Guid; |
| | 0 | 272 | | return true; |
| | | 273 | | |
| | | 274 | | default: |
| | 0 | 275 | | index = 0; |
| | 0 | 276 | | return false; |
| | | 277 | | } |
| | 0 | 278 | | } |
| | | 279 | | |
| | | 280 | | #region Handle Factories |
| | | 281 | | |
| | | 282 | | /// <summary> |
| | | 283 | | /// Creates a handle from a token value. |
| | | 284 | | /// </summary> |
| | | 285 | | /// <exception cref="ArgumentException"> |
| | | 286 | | /// <paramref name="token"/> is not a valid metadata token. |
| | | 287 | | /// It must encode a metadata table entity or an offset in <see cref="HandleKind.UserString"/> heap. |
| | | 288 | | /// </exception> |
| | | 289 | | public static Handle Handle(int token) |
| | 0 | 290 | | { |
| | 0 | 291 | | if (!TokenTypeIds.IsEntityOrUserStringToken(unchecked((uint)token))) |
| | 0 | 292 | | { |
| | 0 | 293 | | Throw.InvalidToken(); |
| | | 294 | | } |
| | | 295 | | |
| | 0 | 296 | | return Metadata.Handle.FromVToken((uint)token); |
| | 0 | 297 | | } |
| | | 298 | | |
| | | 299 | | /// <summary> |
| | | 300 | | /// Creates an entity handle from a token value. |
| | | 301 | | /// </summary> |
| | | 302 | | /// <exception cref="ArgumentException"><paramref name="token"/> is not a valid metadata entity token.</exceptio |
| | | 303 | | public static EntityHandle EntityHandle(int token) |
| | 0 | 304 | | { |
| | 0 | 305 | | if (!TokenTypeIds.IsEntityToken(unchecked((uint)token))) |
| | 0 | 306 | | { |
| | 0 | 307 | | Throw.InvalidToken(); |
| | | 308 | | } |
| | | 309 | | |
| | 0 | 310 | | return new EntityHandle((uint)token); |
| | 0 | 311 | | } |
| | | 312 | | |
| | | 313 | | /// <summary> |
| | | 314 | | /// Creates an <see cref="Metadata.EntityHandle"/> from a token value. |
| | | 315 | | /// </summary> |
| | | 316 | | /// <exception cref="ArgumentException"> |
| | | 317 | | /// <paramref name="tableIndex"/> is not a valid table index.</exception> |
| | | 318 | | public static EntityHandle EntityHandle(TableIndex tableIndex, int rowNumber) |
| | 0 | 319 | | { |
| | 0 | 320 | | return Handle(tableIndex, rowNumber); |
| | 0 | 321 | | } |
| | | 322 | | |
| | | 323 | | /// <summary> |
| | | 324 | | /// Creates an <see cref="Metadata.EntityHandle"/> from a token value. |
| | | 325 | | /// </summary> |
| | | 326 | | /// <exception cref="ArgumentException"> |
| | | 327 | | /// <paramref name="tableIndex"/> is not a valid table index.</exception> |
| | | 328 | | public static EntityHandle Handle(TableIndex tableIndex, int rowNumber) |
| | 0 | 329 | | { |
| | 0 | 330 | | int token = ((int)tableIndex << TokenTypeIds.RowIdBitCount) | rowNumber; |
| | | 331 | | |
| | 0 | 332 | | if (!TokenTypeIds.IsEntityOrUserStringToken(unchecked((uint)token))) |
| | 0 | 333 | | { |
| | 0 | 334 | | Throw.TableIndexOutOfRange(); |
| | | 335 | | } |
| | | 336 | | |
| | 0 | 337 | | return new EntityHandle((uint)token); |
| | 0 | 338 | | } |
| | | 339 | | |
| | | 340 | | private static int ToRowId(int rowNumber) |
| | 0 | 341 | | { |
| | 0 | 342 | | return rowNumber & (int)TokenTypeIds.RIDMask; |
| | 0 | 343 | | } |
| | | 344 | | |
| | | 345 | | public static MethodDefinitionHandle MethodDefinitionHandle(int rowNumber) |
| | 0 | 346 | | { |
| | 0 | 347 | | return Metadata.MethodDefinitionHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 348 | | } |
| | | 349 | | |
| | | 350 | | public static MethodImplementationHandle MethodImplementationHandle(int rowNumber) |
| | 0 | 351 | | { |
| | 0 | 352 | | return Metadata.MethodImplementationHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 353 | | } |
| | | 354 | | |
| | | 355 | | public static MethodSpecificationHandle MethodSpecificationHandle(int rowNumber) |
| | 0 | 356 | | { |
| | 0 | 357 | | return Metadata.MethodSpecificationHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 358 | | } |
| | | 359 | | |
| | | 360 | | public static TypeDefinitionHandle TypeDefinitionHandle(int rowNumber) |
| | 0 | 361 | | { |
| | 0 | 362 | | return Metadata.TypeDefinitionHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 363 | | } |
| | | 364 | | |
| | | 365 | | public static ExportedTypeHandle ExportedTypeHandle(int rowNumber) |
| | 0 | 366 | | { |
| | 0 | 367 | | return Metadata.ExportedTypeHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 368 | | } |
| | | 369 | | |
| | | 370 | | public static TypeReferenceHandle TypeReferenceHandle(int rowNumber) |
| | 0 | 371 | | { |
| | 0 | 372 | | return Metadata.TypeReferenceHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 373 | | } |
| | | 374 | | |
| | | 375 | | public static TypeSpecificationHandle TypeSpecificationHandle(int rowNumber) |
| | 0 | 376 | | { |
| | 0 | 377 | | return Metadata.TypeSpecificationHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 378 | | } |
| | | 379 | | |
| | | 380 | | public static InterfaceImplementationHandle InterfaceImplementationHandle(int rowNumber) |
| | 0 | 381 | | { |
| | 0 | 382 | | return Metadata.InterfaceImplementationHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 383 | | } |
| | | 384 | | |
| | | 385 | | public static MemberReferenceHandle MemberReferenceHandle(int rowNumber) |
| | 0 | 386 | | { |
| | 0 | 387 | | return Metadata.MemberReferenceHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 388 | | } |
| | | 389 | | |
| | | 390 | | public static FieldDefinitionHandle FieldDefinitionHandle(int rowNumber) |
| | 0 | 391 | | { |
| | 0 | 392 | | return Metadata.FieldDefinitionHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 393 | | } |
| | | 394 | | |
| | | 395 | | public static EventDefinitionHandle EventDefinitionHandle(int rowNumber) |
| | 0 | 396 | | { |
| | 0 | 397 | | return Metadata.EventDefinitionHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 398 | | } |
| | | 399 | | |
| | | 400 | | public static PropertyDefinitionHandle PropertyDefinitionHandle(int rowNumber) |
| | 0 | 401 | | { |
| | 0 | 402 | | return Metadata.PropertyDefinitionHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 403 | | } |
| | | 404 | | |
| | | 405 | | public static StandaloneSignatureHandle StandaloneSignatureHandle(int rowNumber) |
| | 0 | 406 | | { |
| | 0 | 407 | | return Metadata.StandaloneSignatureHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 408 | | } |
| | | 409 | | |
| | | 410 | | public static ParameterHandle ParameterHandle(int rowNumber) |
| | 0 | 411 | | { |
| | 0 | 412 | | return Metadata.ParameterHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 413 | | } |
| | | 414 | | |
| | | 415 | | public static GenericParameterHandle GenericParameterHandle(int rowNumber) |
| | 0 | 416 | | { |
| | 0 | 417 | | return Metadata.GenericParameterHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 418 | | } |
| | | 419 | | |
| | | 420 | | public static GenericParameterConstraintHandle GenericParameterConstraintHandle(int rowNumber) |
| | 0 | 421 | | { |
| | 0 | 422 | | return Metadata.GenericParameterConstraintHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 423 | | } |
| | | 424 | | |
| | | 425 | | public static ModuleReferenceHandle ModuleReferenceHandle(int rowNumber) |
| | 0 | 426 | | { |
| | 0 | 427 | | return Metadata.ModuleReferenceHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 428 | | } |
| | | 429 | | |
| | | 430 | | public static AssemblyReferenceHandle AssemblyReferenceHandle(int rowNumber) |
| | 0 | 431 | | { |
| | 0 | 432 | | return Metadata.AssemblyReferenceHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 433 | | } |
| | | 434 | | |
| | | 435 | | public static CustomAttributeHandle CustomAttributeHandle(int rowNumber) |
| | 0 | 436 | | { |
| | 0 | 437 | | return Metadata.CustomAttributeHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 438 | | } |
| | | 439 | | |
| | | 440 | | public static DeclarativeSecurityAttributeHandle DeclarativeSecurityAttributeHandle(int rowNumber) |
| | 0 | 441 | | { |
| | 0 | 442 | | return Metadata.DeclarativeSecurityAttributeHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 443 | | } |
| | | 444 | | |
| | | 445 | | public static ConstantHandle ConstantHandle(int rowNumber) |
| | 0 | 446 | | { |
| | 0 | 447 | | return Metadata.ConstantHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 448 | | } |
| | | 449 | | |
| | | 450 | | public static ManifestResourceHandle ManifestResourceHandle(int rowNumber) |
| | 0 | 451 | | { |
| | 0 | 452 | | return Metadata.ManifestResourceHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 453 | | } |
| | | 454 | | |
| | | 455 | | public static AssemblyFileHandle AssemblyFileHandle(int rowNumber) |
| | 0 | 456 | | { |
| | 0 | 457 | | return Metadata.AssemblyFileHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 458 | | } |
| | | 459 | | |
| | | 460 | | // debug |
| | | 461 | | |
| | | 462 | | public static DocumentHandle DocumentHandle(int rowNumber) |
| | 0 | 463 | | { |
| | 0 | 464 | | return Metadata.DocumentHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 465 | | } |
| | | 466 | | |
| | | 467 | | public static MethodDebugInformationHandle MethodDebugInformationHandle(int rowNumber) |
| | 0 | 468 | | { |
| | 0 | 469 | | return Metadata.MethodDebugInformationHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 470 | | } |
| | | 471 | | |
| | | 472 | | public static LocalScopeHandle LocalScopeHandle(int rowNumber) |
| | 0 | 473 | | { |
| | 0 | 474 | | return Metadata.LocalScopeHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 475 | | } |
| | | 476 | | |
| | | 477 | | public static LocalVariableHandle LocalVariableHandle(int rowNumber) |
| | 0 | 478 | | { |
| | 0 | 479 | | return Metadata.LocalVariableHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 480 | | } |
| | | 481 | | |
| | | 482 | | public static LocalConstantHandle LocalConstantHandle(int rowNumber) |
| | 0 | 483 | | { |
| | 0 | 484 | | return Metadata.LocalConstantHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 485 | | } |
| | | 486 | | |
| | | 487 | | public static ImportScopeHandle ImportScopeHandle(int rowNumber) |
| | 0 | 488 | | { |
| | 0 | 489 | | return Metadata.ImportScopeHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 490 | | } |
| | | 491 | | |
| | | 492 | | public static CustomDebugInformationHandle CustomDebugInformationHandle(int rowNumber) |
| | 0 | 493 | | { |
| | 0 | 494 | | return Metadata.CustomDebugInformationHandle.FromRowId(ToRowId(rowNumber)); |
| | 0 | 495 | | } |
| | | 496 | | |
| | | 497 | | // heaps |
| | | 498 | | |
| | | 499 | | public static UserStringHandle UserStringHandle(int offset) |
| | 0 | 500 | | { |
| | 0 | 501 | | return Metadata.UserStringHandle.FromOffset(offset & (int)TokenTypeIds.RIDMask); |
| | 0 | 502 | | } |
| | | 503 | | |
| | | 504 | | public static StringHandle StringHandle(int offset) |
| | 0 | 505 | | { |
| | 0 | 506 | | return Metadata.StringHandle.FromOffset(offset); |
| | 0 | 507 | | } |
| | | 508 | | |
| | | 509 | | public static BlobHandle BlobHandle(int offset) |
| | 0 | 510 | | { |
| | 0 | 511 | | return Metadata.BlobHandle.FromOffset(offset); |
| | 0 | 512 | | } |
| | | 513 | | |
| | | 514 | | public static GuidHandle GuidHandle(int offset) |
| | 0 | 515 | | { |
| | 0 | 516 | | return Metadata.GuidHandle.FromIndex(offset); |
| | 0 | 517 | | } |
| | | 518 | | |
| | | 519 | | public static DocumentNameBlobHandle DocumentNameBlobHandle(int offset) |
| | 0 | 520 | | { |
| | 0 | 521 | | return Metadata.DocumentNameBlobHandle.FromOffset(offset); |
| | 0 | 522 | | } |
| | | 523 | | |
| | | 524 | | #endregion |
| | | 525 | | } |
| | | 526 | | } |
| | | 527 | | |