mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Use Random.GetString in hosting IdGenerator (#2427)
This commit is contained in:
committed by
GitHub
Unverified
parent
b6c3b8d3f2
commit
7a4f6877c3
@@ -146,6 +146,9 @@ internal sealed partial class IdGenerator
|
||||
const string Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
if (random is not null)
|
||||
{
|
||||
#if NET10_0_OR_GREATER
|
||||
return random.GetString(Chars, stringLength);
|
||||
#else
|
||||
// Use deterministic random generation when seed is provided
|
||||
return string.Create(stringLength, random, static (destination, random) =>
|
||||
{
|
||||
@@ -154,6 +157,7 @@ internal sealed partial class IdGenerator
|
||||
destination[i] = Chars[random.Next(Chars.Length)];
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
// Use cryptographically secure random generation when no seed is provided
|
||||
|
||||
Reference in New Issue
Block a user