| | | 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 | | using System.Diagnostics; |
| | | 5 | | using System.Diagnostics.CodeAnalysis; |
| | | 6 | | using System.Reflection.Metadata.Ecma335; |
| | | 7 | | |
| | | 8 | | namespace System.Reflection.Metadata |
| | | 9 | | { |
| | | 10 | | public readonly struct DocumentHandle : IEquatable<DocumentHandle> |
| | | 11 | | { |
| | | 12 | | private const uint tokenType = TokenTypeIds.Document; |
| | | 13 | | private const byte tokenTypeSmall = (byte)HandleType.Document; |
| | | 14 | | private readonly int _rowId; |
| | | 15 | | |
| | | 16 | | private DocumentHandle(int rowId) |
| | | 17 | | { |
| | | 18 | | Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); |
| | | 19 | | _rowId = rowId; |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | internal static DocumentHandle FromRowId(int rowId) |
| | | 23 | | { |
| | | 24 | | return new DocumentHandle(rowId); |
| | | 25 | | } |
| | | 26 | | |
| | | 27 | | public static implicit operator Handle(DocumentHandle handle) |
| | | 28 | | { |
| | | 29 | | return new Handle(tokenTypeSmall, handle._rowId); |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | public static implicit operator EntityHandle(DocumentHandle handle) |
| | | 33 | | { |
| | | 34 | | return new EntityHandle((uint)(tokenType | handle._rowId)); |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | public static explicit operator DocumentHandle(Handle handle) |
| | | 38 | | { |
| | | 39 | | if (handle.VType != tokenTypeSmall) |
| | | 40 | | { |
| | | 41 | | Throw.InvalidCast(); |
| | | 42 | | } |
| | | 43 | | |
| | | 44 | | return new DocumentHandle(handle.RowId); |
| | | 45 | | } |
| | | 46 | | |
| | | 47 | | public static explicit operator DocumentHandle(EntityHandle handle) |
| | | 48 | | { |
| | | 49 | | if (handle.VType != tokenType) |
| | | 50 | | { |
| | | 51 | | Throw.InvalidCast(); |
| | | 52 | | } |
| | | 53 | | |
| | | 54 | | return new DocumentHandle(handle.RowId); |
| | | 55 | | } |
| | | 56 | | |
| | | 57 | | public bool IsNil |
| | | 58 | | { |
| | | 59 | | get |
| | | 60 | | { |
| | | 61 | | return RowId == 0; |
| | | 62 | | } |
| | | 63 | | } |
| | | 64 | | |
| | | 65 | | internal int RowId { get { return _rowId; } } |
| | | 66 | | |
| | | 67 | | public static bool operator ==(DocumentHandle left, DocumentHandle right) |
| | | 68 | | { |
| | | 69 | | return left._rowId == right._rowId; |
| | | 70 | | } |
| | | 71 | | |
| | | 72 | | public override bool Equals(object? obj) |
| | | 73 | | { |
| | | 74 | | return obj is DocumentHandle documentHandle && documentHandle._rowId == _rowId; |
| | | 75 | | } |
| | | 76 | | |
| | | 77 | | public bool Equals(DocumentHandle other) |
| | | 78 | | { |
| | | 79 | | return _rowId == other._rowId; |
| | | 80 | | } |
| | | 81 | | |
| | | 82 | | public override int GetHashCode() |
| | | 83 | | { |
| | | 84 | | return _rowId.GetHashCode(); |
| | | 85 | | } |
| | | 86 | | |
| | | 87 | | public static bool operator !=(DocumentHandle left, DocumentHandle right) |
| | | 88 | | { |
| | | 89 | | return left._rowId != right._rowId; |
| | | 90 | | } |
| | | 91 | | } |
| | | 92 | | |
| | | 93 | | public readonly struct MethodDebugInformationHandle : IEquatable<MethodDebugInformationHandle> |
| | | 94 | | { |
| | | 95 | | private const uint tokenType = TokenTypeIds.MethodDebugInformation; |
| | | 96 | | private const byte tokenTypeSmall = (byte)HandleType.MethodDebugInformation; |
| | | 97 | | private readonly int _rowId; |
| | | 98 | | |
| | | 99 | | private MethodDebugInformationHandle(int rowId) |
| | | 100 | | { |
| | | 101 | | Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); |
| | | 102 | | _rowId = rowId; |
| | | 103 | | } |
| | | 104 | | |
| | | 105 | | internal static MethodDebugInformationHandle FromRowId(int rowId) |
| | | 106 | | { |
| | | 107 | | return new MethodDebugInformationHandle(rowId); |
| | | 108 | | } |
| | | 109 | | |
| | | 110 | | public static implicit operator Handle(MethodDebugInformationHandle handle) |
| | | 111 | | { |
| | | 112 | | return new Handle(tokenTypeSmall, handle._rowId); |
| | | 113 | | } |
| | | 114 | | |
| | | 115 | | public static implicit operator EntityHandle(MethodDebugInformationHandle handle) |
| | | 116 | | { |
| | | 117 | | return new EntityHandle((uint)(tokenType | handle._rowId)); |
| | | 118 | | } |
| | | 119 | | |
| | | 120 | | public static explicit operator MethodDebugInformationHandle(Handle handle) |
| | | 121 | | { |
| | | 122 | | if (handle.VType != tokenTypeSmall) |
| | | 123 | | { |
| | | 124 | | Throw.InvalidCast(); |
| | | 125 | | } |
| | | 126 | | |
| | | 127 | | return new MethodDebugInformationHandle(handle.RowId); |
| | | 128 | | } |
| | | 129 | | |
| | | 130 | | public static explicit operator MethodDebugInformationHandle(EntityHandle handle) |
| | | 131 | | { |
| | | 132 | | if (handle.VType != tokenType) |
| | | 133 | | { |
| | | 134 | | Throw.InvalidCast(); |
| | | 135 | | } |
| | | 136 | | |
| | | 137 | | return new MethodDebugInformationHandle(handle.RowId); |
| | | 138 | | } |
| | | 139 | | |
| | | 140 | | public bool IsNil |
| | | 141 | | { |
| | | 142 | | get |
| | | 143 | | { |
| | | 144 | | return RowId == 0; |
| | | 145 | | } |
| | | 146 | | } |
| | | 147 | | |
| | | 148 | | internal int RowId { get { return _rowId; } } |
| | | 149 | | |
| | | 150 | | public static bool operator ==(MethodDebugInformationHandle left, MethodDebugInformationHandle right) |
| | | 151 | | { |
| | | 152 | | return left._rowId == right._rowId; |
| | | 153 | | } |
| | | 154 | | |
| | | 155 | | public override bool Equals(object? obj) |
| | | 156 | | { |
| | | 157 | | return obj is MethodDebugInformationHandle mdih && mdih._rowId == _rowId; |
| | | 158 | | } |
| | | 159 | | |
| | | 160 | | public bool Equals(MethodDebugInformationHandle other) |
| | | 161 | | { |
| | | 162 | | return _rowId == other._rowId; |
| | | 163 | | } |
| | | 164 | | |
| | | 165 | | public override int GetHashCode() |
| | | 166 | | { |
| | | 167 | | return _rowId.GetHashCode(); |
| | | 168 | | } |
| | | 169 | | |
| | | 170 | | public static bool operator !=(MethodDebugInformationHandle left, MethodDebugInformationHandle right) |
| | | 171 | | { |
| | | 172 | | return left._rowId != right._rowId; |
| | | 173 | | } |
| | | 174 | | |
| | | 175 | | /// <summary> |
| | | 176 | | /// Returns a handle to <see cref="MethodDefinition"/> corresponding to this handle. |
| | | 177 | | /// </summary> |
| | | 178 | | /// <remarks> |
| | | 179 | | /// The resulting handle is only valid within the context of a <see cref="MetadataReader"/> open on the type sys |
| | | 180 | | /// which in case of standalone PDB file is a different reader than the one containing this method debug informa |
| | | 181 | | /// </remarks> |
| | | 182 | | public MethodDefinitionHandle ToDefinitionHandle() |
| | | 183 | | { |
| | | 184 | | return MethodDefinitionHandle.FromRowId(_rowId); |
| | | 185 | | } |
| | | 186 | | } |
| | | 187 | | |
| | | 188 | | public readonly struct LocalScopeHandle : IEquatable<LocalScopeHandle> |
| | | 189 | | { |
| | | 190 | | private const uint tokenType = TokenTypeIds.LocalScope; |
| | | 191 | | private const byte tokenTypeSmall = (byte)HandleType.LocalScope; |
| | | 192 | | private readonly int _rowId; |
| | | 193 | | |
| | | 194 | | private LocalScopeHandle(int rowId) |
| | | 195 | | { |
| | | 196 | | Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); |
| | | 197 | | _rowId = rowId; |
| | | 198 | | } |
| | | 199 | | |
| | | 200 | | internal static LocalScopeHandle FromRowId(int rowId) |
| | | 201 | | { |
| | | 202 | | return new LocalScopeHandle(rowId); |
| | | 203 | | } |
| | | 204 | | |
| | | 205 | | public static implicit operator Handle(LocalScopeHandle handle) |
| | | 206 | | { |
| | | 207 | | return new Handle(tokenTypeSmall, handle._rowId); |
| | | 208 | | } |
| | | 209 | | |
| | | 210 | | public static implicit operator EntityHandle(LocalScopeHandle handle) |
| | | 211 | | { |
| | | 212 | | return new EntityHandle((uint)(tokenType | handle._rowId)); |
| | | 213 | | } |
| | | 214 | | |
| | | 215 | | public static explicit operator LocalScopeHandle(Handle handle) |
| | | 216 | | { |
| | | 217 | | if (handle.VType != tokenTypeSmall) |
| | | 218 | | { |
| | | 219 | | Throw.InvalidCast(); |
| | | 220 | | } |
| | | 221 | | |
| | | 222 | | return new LocalScopeHandle(handle.RowId); |
| | | 223 | | } |
| | | 224 | | |
| | | 225 | | public static explicit operator LocalScopeHandle(EntityHandle handle) |
| | | 226 | | { |
| | | 227 | | if (handle.VType != tokenType) |
| | | 228 | | { |
| | | 229 | | Throw.InvalidCast(); |
| | | 230 | | } |
| | | 231 | | |
| | | 232 | | return new LocalScopeHandle(handle.RowId); |
| | | 233 | | } |
| | | 234 | | |
| | | 235 | | public bool IsNil |
| | | 236 | | { |
| | | 237 | | get |
| | | 238 | | { |
| | | 239 | | return RowId == 0; |
| | | 240 | | } |
| | | 241 | | } |
| | | 242 | | |
| | | 243 | | internal int RowId { get { return _rowId; } } |
| | | 244 | | |
| | | 245 | | public static bool operator ==(LocalScopeHandle left, LocalScopeHandle right) |
| | | 246 | | { |
| | | 247 | | return left._rowId == right._rowId; |
| | | 248 | | } |
| | | 249 | | |
| | | 250 | | public override bool Equals(object? obj) |
| | | 251 | | { |
| | | 252 | | return obj is LocalScopeHandle lsh && lsh._rowId == _rowId; |
| | | 253 | | } |
| | | 254 | | |
| | | 255 | | public bool Equals(LocalScopeHandle other) |
| | | 256 | | { |
| | | 257 | | return _rowId == other._rowId; |
| | | 258 | | } |
| | | 259 | | |
| | | 260 | | public override int GetHashCode() |
| | | 261 | | { |
| | | 262 | | return _rowId.GetHashCode(); |
| | | 263 | | } |
| | | 264 | | |
| | | 265 | | public static bool operator !=(LocalScopeHandle left, LocalScopeHandle right) |
| | | 266 | | { |
| | | 267 | | return left._rowId != right._rowId; |
| | | 268 | | } |
| | | 269 | | } |
| | | 270 | | |
| | | 271 | | public readonly struct LocalVariableHandle : IEquatable<LocalVariableHandle> |
| | | 272 | | { |
| | | 273 | | private const uint tokenType = TokenTypeIds.LocalVariable; |
| | | 274 | | private const byte tokenTypeSmall = (byte)HandleType.LocalVariable; |
| | | 275 | | private readonly int _rowId; |
| | | 276 | | |
| | | 277 | | private LocalVariableHandle(int rowId) |
| | | 278 | | { |
| | | 279 | | Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); |
| | | 280 | | _rowId = rowId; |
| | | 281 | | } |
| | | 282 | | |
| | | 283 | | internal static LocalVariableHandle FromRowId(int rowId) |
| | | 284 | | { |
| | | 285 | | return new LocalVariableHandle(rowId); |
| | | 286 | | } |
| | | 287 | | |
| | | 288 | | public static implicit operator Handle(LocalVariableHandle handle) |
| | | 289 | | { |
| | | 290 | | return new Handle(tokenTypeSmall, handle._rowId); |
| | | 291 | | } |
| | | 292 | | |
| | | 293 | | public static implicit operator EntityHandle(LocalVariableHandle handle) |
| | | 294 | | { |
| | | 295 | | return new EntityHandle((uint)(tokenType | handle._rowId)); |
| | | 296 | | } |
| | | 297 | | |
| | | 298 | | public static explicit operator LocalVariableHandle(Handle handle) |
| | | 299 | | { |
| | | 300 | | if (handle.VType != tokenTypeSmall) |
| | | 301 | | { |
| | | 302 | | Throw.InvalidCast(); |
| | | 303 | | } |
| | | 304 | | |
| | | 305 | | return new LocalVariableHandle(handle.RowId); |
| | | 306 | | } |
| | | 307 | | |
| | | 308 | | public static explicit operator LocalVariableHandle(EntityHandle handle) |
| | | 309 | | { |
| | | 310 | | if (handle.VType != tokenType) |
| | | 311 | | { |
| | | 312 | | Throw.InvalidCast(); |
| | | 313 | | } |
| | | 314 | | |
| | | 315 | | return new LocalVariableHandle(handle.RowId); |
| | | 316 | | } |
| | | 317 | | |
| | | 318 | | public bool IsNil |
| | | 319 | | { |
| | | 320 | | get |
| | | 321 | | { |
| | | 322 | | return RowId == 0; |
| | | 323 | | } |
| | | 324 | | } |
| | | 325 | | |
| | | 326 | | internal int RowId { get { return _rowId; } } |
| | | 327 | | |
| | | 328 | | public static bool operator ==(LocalVariableHandle left, LocalVariableHandle right) |
| | | 329 | | { |
| | | 330 | | return left._rowId == right._rowId; |
| | | 331 | | } |
| | | 332 | | |
| | | 333 | | public override bool Equals(object? obj) |
| | | 334 | | { |
| | | 335 | | return obj is LocalVariableHandle lvh && lvh._rowId == _rowId; |
| | | 336 | | } |
| | | 337 | | |
| | | 338 | | public bool Equals(LocalVariableHandle other) |
| | | 339 | | { |
| | | 340 | | return _rowId == other._rowId; |
| | | 341 | | } |
| | | 342 | | |
| | | 343 | | public override int GetHashCode() |
| | | 344 | | { |
| | | 345 | | return _rowId.GetHashCode(); |
| | | 346 | | } |
| | | 347 | | |
| | | 348 | | public static bool operator !=(LocalVariableHandle left, LocalVariableHandle right) |
| | | 349 | | { |
| | | 350 | | return left._rowId != right._rowId; |
| | | 351 | | } |
| | | 352 | | } |
| | | 353 | | |
| | | 354 | | public readonly struct LocalConstantHandle : IEquatable<LocalConstantHandle> |
| | | 355 | | { |
| | | 356 | | private const uint tokenType = TokenTypeIds.LocalConstant; |
| | | 357 | | private const byte tokenTypeSmall = (byte)HandleType.LocalConstant; |
| | | 358 | | private readonly int _rowId; |
| | | 359 | | |
| | | 360 | | private LocalConstantHandle(int rowId) |
| | | 361 | | { |
| | | 362 | | Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); |
| | | 363 | | _rowId = rowId; |
| | | 364 | | } |
| | | 365 | | |
| | | 366 | | internal static LocalConstantHandle FromRowId(int rowId) |
| | | 367 | | { |
| | | 368 | | return new LocalConstantHandle(rowId); |
| | | 369 | | } |
| | | 370 | | |
| | | 371 | | public static implicit operator Handle(LocalConstantHandle handle) |
| | | 372 | | { |
| | | 373 | | return new Handle(tokenTypeSmall, handle._rowId); |
| | | 374 | | } |
| | | 375 | | |
| | | 376 | | public static implicit operator EntityHandle(LocalConstantHandle handle) |
| | | 377 | | { |
| | | 378 | | return new EntityHandle((uint)(tokenType | handle._rowId)); |
| | | 379 | | } |
| | | 380 | | |
| | | 381 | | public static explicit operator LocalConstantHandle(Handle handle) |
| | | 382 | | { |
| | | 383 | | if (handle.VType != tokenTypeSmall) |
| | | 384 | | { |
| | | 385 | | Throw.InvalidCast(); |
| | | 386 | | } |
| | | 387 | | |
| | | 388 | | return new LocalConstantHandle(handle.RowId); |
| | | 389 | | } |
| | | 390 | | |
| | | 391 | | public static explicit operator LocalConstantHandle(EntityHandle handle) |
| | | 392 | | { |
| | | 393 | | if (handle.VType != tokenType) |
| | | 394 | | { |
| | | 395 | | Throw.InvalidCast(); |
| | | 396 | | } |
| | | 397 | | |
| | | 398 | | return new LocalConstantHandle(handle.RowId); |
| | | 399 | | } |
| | | 400 | | |
| | | 401 | | public bool IsNil |
| | | 402 | | { |
| | | 403 | | get |
| | | 404 | | { |
| | | 405 | | return RowId == 0; |
| | | 406 | | } |
| | | 407 | | } |
| | | 408 | | |
| | | 409 | | internal int RowId { get { return _rowId; } } |
| | | 410 | | |
| | | 411 | | public static bool operator ==(LocalConstantHandle left, LocalConstantHandle right) |
| | | 412 | | { |
| | | 413 | | return left._rowId == right._rowId; |
| | | 414 | | } |
| | | 415 | | |
| | | 416 | | public override bool Equals([NotNullWhen(true)] object? obj) |
| | | 417 | | { |
| | | 418 | | return obj is LocalConstantHandle lch && lch._rowId == _rowId; |
| | | 419 | | } |
| | | 420 | | |
| | | 421 | | public bool Equals(LocalConstantHandle other) |
| | | 422 | | { |
| | | 423 | | return _rowId == other._rowId; |
| | | 424 | | } |
| | | 425 | | |
| | | 426 | | public override int GetHashCode() |
| | | 427 | | { |
| | | 428 | | return _rowId.GetHashCode(); |
| | | 429 | | } |
| | | 430 | | |
| | | 431 | | public static bool operator !=(LocalConstantHandle left, LocalConstantHandle right) |
| | | 432 | | { |
| | | 433 | | return left._rowId != right._rowId; |
| | | 434 | | } |
| | | 435 | | } |
| | | 436 | | |
| | | 437 | | public readonly struct ImportScopeHandle : IEquatable<ImportScopeHandle> |
| | | 438 | | { |
| | | 439 | | private const uint tokenType = TokenTypeIds.ImportScope; |
| | | 440 | | private const byte tokenTypeSmall = (byte)HandleType.ImportScope; |
| | | 441 | | private readonly int _rowId; |
| | | 442 | | |
| | | 443 | | private ImportScopeHandle(int rowId) |
| | 0 | 444 | | { |
| | 0 | 445 | | Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); |
| | 0 | 446 | | _rowId = rowId; |
| | 0 | 447 | | } |
| | | 448 | | |
| | | 449 | | internal static ImportScopeHandle FromRowId(int rowId) |
| | 0 | 450 | | { |
| | 0 | 451 | | return new ImportScopeHandle(rowId); |
| | 0 | 452 | | } |
| | | 453 | | |
| | | 454 | | public static implicit operator Handle(ImportScopeHandle handle) |
| | 0 | 455 | | { |
| | 0 | 456 | | return new Handle(tokenTypeSmall, handle._rowId); |
| | 0 | 457 | | } |
| | | 458 | | |
| | | 459 | | public static implicit operator EntityHandle(ImportScopeHandle handle) |
| | 0 | 460 | | { |
| | 0 | 461 | | return new EntityHandle((uint)(tokenType | handle._rowId)); |
| | 0 | 462 | | } |
| | | 463 | | |
| | | 464 | | public static explicit operator ImportScopeHandle(Handle handle) |
| | 0 | 465 | | { |
| | 0 | 466 | | if (handle.VType != tokenTypeSmall) |
| | 0 | 467 | | { |
| | 0 | 468 | | Throw.InvalidCast(); |
| | | 469 | | } |
| | | 470 | | |
| | 0 | 471 | | return new ImportScopeHandle(handle.RowId); |
| | 0 | 472 | | } |
| | | 473 | | |
| | | 474 | | public static explicit operator ImportScopeHandle(EntityHandle handle) |
| | 0 | 475 | | { |
| | 0 | 476 | | if (handle.VType != tokenType) |
| | 0 | 477 | | { |
| | 0 | 478 | | Throw.InvalidCast(); |
| | | 479 | | } |
| | | 480 | | |
| | 0 | 481 | | return new ImportScopeHandle(handle.RowId); |
| | 0 | 482 | | } |
| | | 483 | | |
| | | 484 | | public bool IsNil |
| | | 485 | | { |
| | | 486 | | get |
| | 0 | 487 | | { |
| | 0 | 488 | | return RowId == 0; |
| | 0 | 489 | | } |
| | | 490 | | } |
| | | 491 | | |
| | 0 | 492 | | internal int RowId { get { return _rowId; } } |
| | | 493 | | |
| | | 494 | | public static bool operator ==(ImportScopeHandle left, ImportScopeHandle right) |
| | 0 | 495 | | { |
| | 0 | 496 | | return left._rowId == right._rowId; |
| | 0 | 497 | | } |
| | | 498 | | |
| | | 499 | | public override bool Equals([NotNullWhen(true)] object? obj) |
| | 0 | 500 | | { |
| | 0 | 501 | | return obj is ImportScopeHandle ish && ish._rowId == _rowId; |
| | 0 | 502 | | } |
| | | 503 | | |
| | | 504 | | public bool Equals(ImportScopeHandle other) |
| | 0 | 505 | | { |
| | 0 | 506 | | return _rowId == other._rowId; |
| | 0 | 507 | | } |
| | | 508 | | |
| | | 509 | | public override int GetHashCode() |
| | 0 | 510 | | { |
| | 0 | 511 | | return _rowId.GetHashCode(); |
| | 0 | 512 | | } |
| | | 513 | | |
| | | 514 | | public static bool operator !=(ImportScopeHandle left, ImportScopeHandle right) |
| | 0 | 515 | | { |
| | 0 | 516 | | return left._rowId != right._rowId; |
| | 0 | 517 | | } |
| | | 518 | | } |
| | | 519 | | |
| | | 520 | | public readonly struct CustomDebugInformationHandle : IEquatable<CustomDebugInformationHandle> |
| | | 521 | | { |
| | | 522 | | private const uint tokenType = TokenTypeIds.CustomDebugInformation; |
| | | 523 | | private const byte tokenTypeSmall = (byte)HandleType.CustomDebugInformation; |
| | | 524 | | private readonly int _rowId; |
| | | 525 | | |
| | | 526 | | private CustomDebugInformationHandle(int rowId) |
| | | 527 | | { |
| | | 528 | | Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); |
| | | 529 | | _rowId = rowId; |
| | | 530 | | } |
| | | 531 | | |
| | | 532 | | internal static CustomDebugInformationHandle FromRowId(int rowId) |
| | | 533 | | { |
| | | 534 | | return new CustomDebugInformationHandle(rowId); |
| | | 535 | | } |
| | | 536 | | |
| | | 537 | | public static implicit operator Handle(CustomDebugInformationHandle handle) |
| | | 538 | | { |
| | | 539 | | return new Handle(tokenTypeSmall, handle._rowId); |
| | | 540 | | } |
| | | 541 | | |
| | | 542 | | public static implicit operator EntityHandle(CustomDebugInformationHandle handle) |
| | | 543 | | { |
| | | 544 | | return new EntityHandle((uint)(tokenType | handle._rowId)); |
| | | 545 | | } |
| | | 546 | | |
| | | 547 | | public static explicit operator CustomDebugInformationHandle(Handle handle) |
| | | 548 | | { |
| | | 549 | | if (handle.VType != tokenTypeSmall) |
| | | 550 | | { |
| | | 551 | | Throw.InvalidCast(); |
| | | 552 | | } |
| | | 553 | | |
| | | 554 | | return new CustomDebugInformationHandle(handle.RowId); |
| | | 555 | | } |
| | | 556 | | |
| | | 557 | | public static explicit operator CustomDebugInformationHandle(EntityHandle handle) |
| | | 558 | | { |
| | | 559 | | if (handle.VType != tokenType) |
| | | 560 | | { |
| | | 561 | | Throw.InvalidCast(); |
| | | 562 | | } |
| | | 563 | | |
| | | 564 | | return new CustomDebugInformationHandle(handle.RowId); |
| | | 565 | | } |
| | | 566 | | |
| | | 567 | | public bool IsNil |
| | | 568 | | { |
| | | 569 | | get |
| | | 570 | | { |
| | | 571 | | return RowId == 0; |
| | | 572 | | } |
| | | 573 | | } |
| | | 574 | | |
| | | 575 | | internal int RowId { get { return _rowId; } } |
| | | 576 | | |
| | | 577 | | public static bool operator ==(CustomDebugInformationHandle left, CustomDebugInformationHandle right) |
| | | 578 | | { |
| | | 579 | | return left._rowId == right._rowId; |
| | | 580 | | } |
| | | 581 | | |
| | | 582 | | public override bool Equals([NotNullWhen(true)] object? obj) |
| | | 583 | | { |
| | | 584 | | return obj is CustomDebugInformationHandle cdih && cdih._rowId == _rowId; |
| | | 585 | | } |
| | | 586 | | |
| | | 587 | | public bool Equals(CustomDebugInformationHandle other) |
| | | 588 | | { |
| | | 589 | | return _rowId == other._rowId; |
| | | 590 | | } |
| | | 591 | | |
| | | 592 | | public override int GetHashCode() |
| | | 593 | | { |
| | | 594 | | return _rowId.GetHashCode(); |
| | | 595 | | } |
| | | 596 | | |
| | | 597 | | public static bool operator !=(CustomDebugInformationHandle left, CustomDebugInformationHandle right) |
| | | 598 | | { |
| | | 599 | | return left._rowId != right._rowId; |
| | | 600 | | } |
| | | 601 | | } |
| | | 602 | | } |
| | | 603 | | |