/// <summary> /// Creates an entity handle from a token value. /// </summary> /// <exception cref="ArgumentException"><paramref name="token"/> is not a valid metadata entity token.</exception> public static EntityHandle EntityHandle(int token) { if (!TokenTypeIds.IsEntityToken(unchecked ((uint)token))) { Throw.InvalidToken(); } return(new EntityHandle((uint)token)); }
/// <summary> /// Creates a handle from a token value. /// </summary> /// <exception cref="ArgumentException"> /// <paramref name="token"/> is not a valid metadata token. /// It must encode a metadata table entity or an offset in <see cref="HandleKind.UserString"/> heap. /// </exception> public static Handle Handle(int token) { if (!TokenTypeIds.IsEntityOrUserStringToken(unchecked ((uint)token))) { Throw.InvalidToken(); } return(Metadata.Handle.FromVToken((uint)token)); }
private DocumentHandle ReadDocumentHandle() { int rowId = _reader.ReadCompressedInteger(); if (rowId == 0 || !TokenTypeIds.IsValidRowId(rowId)) { Throw.InvalidHandle(); } return DocumentHandle.FromRowId(rowId); }
/// <summary> /// Creates an <see cref="Metadata.EntityHandle"/> from a token value. /// </summary> /// <exception cref="ArgumentException"> /// <paramref name="tableIndex"/> is not a valid table index.</exception> public static EntityHandle Handle(TableIndex tableIndex, int rowNumber) { int token = ((int)tableIndex << TokenTypeIds.RowIdBitCount) | rowNumber; if (!TokenTypeIds.IsEntityOrUserStringToken(unchecked ((uint)token))) { Throw.TableIndexOutOfRange(); } return(new EntityHandle((uint)token)); }
// When reference has at most 24 bits. internal int PeekReference(int offset, bool smallRefSize) { if (smallRefSize) { return(PeekUInt16(offset)); } uint value = PeekUInt32(offset); if (!TokenTypeIds.IsValidRowId(value)) { Throw.ReferenceOverflow(); } return((int)value); }
public void CompareTokens() { Assert.True(TokenTypeIds.CompareTokens(0x02000001, 0x02000002) < 0); Assert.True(TokenTypeIds.CompareTokens(0x02000002, 0x02000001) > 0); Assert.True(TokenTypeIds.CompareTokens(0x02000001, 0x02000001) == 0); // token type is ignored Assert.True(TokenTypeIds.CompareTokens(0x20000001, 0x21000002) < 0); // virtual tokens follow non-virtual: Assert.True(TokenTypeIds.CompareTokens(0x82000001, 0x02000002) > 0); Assert.True(TokenTypeIds.CompareTokens(0x02000002, 0x82000001) < 0); Assert.True(TokenTypeIds.CompareTokens(0x82000001, 0x82000001) == 0); // make sure we won't overflow for extreme values: Assert.True(TokenTypeIds.CompareTokens(0xffffffff, 0) > 0); Assert.True(TokenTypeIds.CompareTokens(0, 0xffffffff) < 0); Assert.True(TokenTypeIds.CompareTokens(0xfffffffe, 0xffffffff) < 0); Assert.True(TokenTypeIds.CompareTokens(0xffffffff, 0xfffffffe) > 0); Assert.True(TokenTypeIds.CompareTokens(0xffffffff, 0xffffffff) == 0); }
private MethodDebugInformationHandle(int rowId) { Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); _rowId = rowId; }
private DocumentHandle(int rowId) { Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); _rowId = rowId; }
public int Compare(Handle x, Handle y) { return(TokenTypeIds.CompareTokens(x.value, y.value)); }
private ImportScopeHandle(int rowId) { Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); _rowId = rowId; }
private LocalConstantHandle(int rowId) { Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); _rowId = rowId; }
private LocalVariableHandle(int rowId) { Debug.Assert(TokenTypeIds.IsValidRowId(rowId)); _rowId = rowId; }