Skip to content

Commit 8753d56

Browse files
committed
Freeze TypeInfoCollection.typeTable after locking
1 parent a6f3b1c commit 8753d56

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Orm/Xtensive.Orm/Orm/Model/TypeInfoCollection.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
// Created by: Dmitri Maximov
55
// Created: 2007.08.27
66

7-
using System;
8-
using System.Collections.Generic;
9-
using System.Linq;
7+
using System.Collections.Frozen;
108
using Xtensive.Collections;
119
using Xtensive.Core;
1210
using Xtensive.Reflection;
@@ -21,7 +19,7 @@ public sealed class TypeInfoCollection
2119
: NodeCollection<TypeInfo>,
2220
IFilterable<TypeAttributes, TypeInfo>
2321
{
24-
private readonly Dictionary<Type, TypeInfo> typeTable = new();
22+
private IDictionary<Type, TypeInfo> typeTable = new Dictionary<Type, TypeInfo>();
2523
private readonly Dictionary<string, TypeInfo> fullNameTable = new();
2624

2725
private TypeIdRegistry typeIdRegistry;
@@ -253,6 +251,11 @@ protected override string GetExceptionMessage(string key)
253251
+ " You might have forgotten to register type {0} as an element of domain model.", key);
254252
}
255253

254+
public override void Lock(bool recursive)
255+
{
256+
base.Lock(recursive);
257+
typeTable = typeTable.ToFrozenDictionary();
258+
}
256259

257260
// Constructors
258261

0 commit comments

Comments
 (0)