Skip to content

Commit d199834

Browse files
committed
Handles scenario of non throwing failure to create instance
1 parent 528ac8d commit d199834

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Generators/Types/ReadOnlyDictionaryGenerator.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ object IAutoFakerGenerator.Generate(AutoFakerContext context)
2626
{
2727
try
2828
{
29-
items = (IDictionary<TKey, TValue>)context.CachedType.CreateInstance();
29+
items = (IDictionary<TKey, TValue>) context.CachedType.CreateInstance();
30+
31+
if (items == null)
32+
items = new Dictionary<TKey, TValue>();
3033
}
3134
catch //(Exception e)
3235
{

0 commit comments

Comments
 (0)