Skip to content

Commit 95581b5

Browse files
committed
ColumnCollection and ColumnGroupCollection: unsafety notifier
1 parent c23efa8 commit 95581b5

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Orm/Xtensive.Orm/Orm/Rse/ColumnCollection.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,16 @@ public ColumnCollection Alias(string alias)
122122
/// Initializes a new instance of this class.
123123
/// </summary>
124124
/// <param name="columns">Collection of items to add.</param>
125+
/// <remarks>
126+
/// <paramref name="columns"/> is used to initialize inner field directly
127+
/// to save time on avoiding collection copy. If you pass an <see cref="IReadOnlyList{Column}"/>
128+
/// implementor that, in fact, can be changed, make sure the passed collection doesn't change afterwards.
129+
/// Ideally, use arrays instead of <see cref="List{T}"/> or similar collections.
130+
/// Changing the passed collection afterwards will lead to unpredictable results.
131+
/// </remarks>
125132
public ColumnCollection(IReadOnlyList<Column> columns)
126133
{
134+
//!!! Direct initialization by parameter is unsafe performance optimization: See remarks in ctor summary!
127135
this.columns = columns;
128136
var count = this.columns.Count;
129137
nameIndex = new Dictionary<string, int>(count);

Orm/Xtensive.Orm/Orm/Rse/ColumnGroupCollection.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,16 @@ public static ColumnGroupCollection Empty {
5555
/// Initializes a new instance of this class.
5656
/// </summary>
5757
/// <param name="items">The collection items.</param>
58+
/// <remarks>
59+
/// <paramref name="items"/> is used to initialize inner field directly
60+
/// to save time on avoiding collection copy. If you pass an <see cref="IReadOnlyList{ColumnGroup}"/>
61+
/// implementor that, in fact, can be changed, make sure the passed collection doesn't change afterwards.
62+
/// Ideally, use arrays instead of <see cref="List{T}"/> or similar collections.
63+
/// Changing the passed collection afterwards will lead to unpredictable results.
64+
/// </remarks>
5865
public ColumnGroupCollection(IReadOnlyList<ColumnGroup> items)
5966
{
67+
//!!! Direct initialization by parameter is unsafe performance optimization: See remark in ctor summary!
6068
this.items = items;
6169
}
6270
}

0 commit comments

Comments
 (0)