修复根据index计算name的bug

backup
walon 2025-04-16 09:08:42 +08:00
parent dcf7fd3ae5
commit 632725f230
1 changed files with 11 additions and 4 deletions

View File

@ -20,10 +20,17 @@ namespace Obfuz.Rename
public string GetNewName(string originalName)
{
if (_nextIndex >= _wordSet.Count)
throw new InvalidOperationException("No more names available in the word set.");
string newName = _wordSet[_nextIndex++];
return newName;
var nameBuilder = new StringBuilder();
for (int i = _nextIndex++; ;)
{
nameBuilder.Append(_wordSet[i % _wordSet.Count]);
i = i / _wordSet.Count;
if (i == 0)
{
break;
}
}
return nameBuilder.ToString();
}
}