Skip to content

Commit e1e971e

Browse files
add ValuesGenerator change
1 parent cfa7ca5 commit e1e971e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/harness/BenchmarkDotNet.Extensions/ValuesGenerator.cs

+9
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ private static T GenerateValue<T>(Random random)
112112
return (T)(object)(random.NextDouble() > 0.5);
113113
if (typeof(T) == typeof(string))
114114
return (T)(object)GenerateRandomString(random, 1, 50);
115+
if (typeof(T) == typeof(Guid))
116+
return (T)(object)GenerateRandomGuid(random);
115117

116118
throw new NotImplementedException($"{typeof(T).Name} is not implemented");
117119
}
@@ -135,5 +137,12 @@ private static string GenerateRandomString(Random random, int minLength, int max
135137

136138
return builder.ToString();
137139
}
140+
141+
private static Guid GenerateRandomGuid(Random random)
142+
{
143+
byte[] bytes = new byte[16];
144+
random.NextBytes(bytes);
145+
return new Guid(bytes);
146+
}
138147
}
139148
}

0 commit comments

Comments
 (0)