/// <summary> /// Determines the next metadata token for provided member and assigns it. /// </summary> /// <remarks>This method only succeeds when new or copied member is provided</remarks> /// <exception cref="ArgumentNullException">Occurs when <paramref name="member"/> is null</exception> /// <exception cref="ArgumentException"> /// Occurs when <paramref name="member"/> is already assigned a <see cref="MetadataToken"/> /// </exception> /// <param name="member">The member to assign a new metadata token.</param> public void AssignNextAvailableToken(MetadataMember member) { if (member is null) { throw new ArgumentNullException(nameof(member)); } if (member.MetadataToken.Rid != 0) { throw new ArgumentException("Only new members can be assigned a new metadata token"); } var index = member.MetadataToken.Table; member.MetadataToken = GetNextAvailableToken(index); _buckets[(int)index].AssignedMembers.Add(member); }
/// <summary> /// Determines the next metadata token for provided member and asigns it /// </summary> /// <remarks>This method only succeeds when new or copied memeber is provided</remarks> /// <exception cref="ArgumentNullException">Occurs when <paramref name="member"/> is null</exception> /// <exception cref="ArgumentException">Occurs when <paramref name="member"/> is already assigned a <see cref="MetadataToken"/></exception> /// <param name="member"></param> public void AssignNextAvailableToken(MetadataMember member) { if (member is null) { throw new ArgumentNullException(nameof(member)); } if (member.MetadataToken.Rid != 0) { throw new ArgumentException("Only new members can be assigned a new metadata token"); } var index = member.MetadataToken.Table; var token = GetNextAvailableToken(index); member.MetadataToken = token; var nextToken = new MetadataToken(index, token.Rid + 1); _nextTokens[index] = nextToken; }