diff --git a/src/CommunityToolkit.Mvvm.SourceGenerators/Helpers/HashCode.cs b/src/CommunityToolkit.Mvvm.SourceGenerators/Helpers/HashCode.cs index bd615271c..0548c4467 100644 --- a/src/CommunityToolkit.Mvvm.SourceGenerators/Helpers/HashCode.cs +++ b/src/CommunityToolkit.Mvvm.SourceGenerators/Helpers/HashCode.cs @@ -35,7 +35,10 @@ private static unsafe uint GenerateGlobalSeed() { byte[] bytes = new byte[4]; - RandomNumberGenerator.Create().GetBytes(bytes); + using (RandomNumberGenerator generator = RandomNumberGenerator.Create()) + { + generator.GetBytes(bytes); + } return BitConverter.ToUInt32(bytes, 0); } @@ -182,4 +185,4 @@ private static uint RotateLeft(uint value, int offset) { return (value << offset) | (value >> (32 - offset)); } -} \ No newline at end of file +}